TMPAPI

Getting Started Annotations Placeholders API URL Request Response Service Spec

Request

The server accepts any HTTP request methods and CORS (Cross-Origin Resource Sharing).

As a default status, the server will sends "Allow: OPTIONS, HEAD, GET, POST" response header when requesting OPTIONS.

And the server accepts "X-Data-Name" request header instead of specify the data-name inside a URL.

REST API

GET https://api.tmpapi.dev/rest/data-name/users

###

POST https://api.tmpapi.dev/rest/users
X-Data-Name: data-name

GraphQL API

POST https://api.tmpapi.dev/graphql/data-name
Content-Type: application/json

{
  "query": "{users{id name type}}"
}

###

POST https://api.tmpapi.dev/graphql
X-Data-Name: data-name
Content-Type: application/json

{
  "query": "{users{id name type}}"
}

REST API

Available Content-Type for a request body:

Available query strings:

Data source

{
  "users": [
    "@repeat(2)",
    {"id": "%index%", "name": "User %index%", "type": "admin"},
    {"id": "%index%", "name": "User %index%", "type": "stuff"}
  ]
}

Request

GET https://api.tmpapi.dev/rest/data-name/users?filter=admin&sort=name&order=asc&limit=10&offset=0

Response

200 OK
Content-Type: application/json; charset=utf-8

{
  "data": [
    {"id": 0, "name": "User 0", "type": "admin"},
    {"id": 2, "name": "User 2", "type": "admin"}
  ]
}

For a REST API, you can configure a response JSON format.

GraphQL API

The server supports GraphQL query operation with fields, arguments, aliases, fragments, operation name and variables. However, TMPAPI's GraphQL has no schemas and types features so some definitions (like inline fragments, directives) are ignored and the server will emit that information as an error.

Available Content-Type for a request body:

Available field arguments:

Data source

{
  "users": [
    "@repeat(2)",
    {"id": "%index%", "name": "User %index%", "type": "admin"},
    {"id": "%index%", "name": "User %index%", "type": "stuff"}
  ]
}

Request

POST https://api.tmpapi.dev/graphql
X-Data-Name: data-name
Content-Type: application/graphql

query UsersAndUser($offset: Int = 0) {
  users(filter: "admin", sort: "name", order: "asc", limit: 10, offset: $offset) {
    ...userFields
  }
  user: users(id: 1) {
    ...userFields
  }
}

fragment userFields on User {
  id
  name
  type
}

Response

200 OK
Content-Type: application/json; charset=utf-8

{
  "data": {
    "users": [
      {"id": 0, "name": "User 0", "type": "admin"},
      {"id": 2, "name": "User 2", "type": "admin"}
    ],
    "user": [
      {"id": 1, "name": "User 1", "type": "stuff"}
    ]
  }
}