MENU navbar-image
bash javascript php python ruby

Introduction

Start (and never finish) side projects with this API.

The SideProject API is a sample API, built to demonstrate Scribe's capabilities.

Lke many side projects, it is itself an unfinished API, but hopefully it should be enough to convince you to try Scribe out.😉 You can check out the source code on GitHub.

Base URL

http://testapi.com

Authenticating requests

This API is authenticated by sending an Authorization header with the value "Bearer {YOUR_AUTH_KEY}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

You can retrieve your token by using the users/auth endpoint.

Dummy endpoints

Nested fields

Example request:
curl --request POST \
    "http://testapi.com/api/nested" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "data[name]=et" \
    --form "data[size]=5" \
    --form "data[things][]=et" \
    --form "data[objects][][a]=et" \
    --form "data[objects][][b]=et" \
    --form "data[picture]=@C:\Users\shalvah\AppData\Local\Temp\phpBA5F.tmp" 
const url = new URL(
    "http://testapi.com/api/nested"
);

const headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('data[name]', 'et');
body.append('data[size]', '5');
body.append('data[things][]', 'et');
body.append('data[objects][][a]', 'et');
body.append('data[objects][][b]', 'et');
body.append('data[picture]', document.querySelector('input[name="data[picture]"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://testapi.com/api/nested',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'data[name]',
                'contents' => 'et'
            ],
            [
                'name' => 'data[size]',
                'contents' => '5'
            ],
            [
                'name' => 'data[things][]',
                'contents' => 'et'
            ],
            [
                'name' => 'data[objects][][a]',
                'contents' => 'et'
            ],
            [
                'name' => 'data[objects][][b]',
                'contents' => 'et'
            ],
            [
                'name' => 'data[picture]',
                'contents' => fopen('C:\Users\shalvah\AppData\Local\Temp\phpBA5F.tmp', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/nested'
files = {
  'data[picture]': open('C:\Users\shalvah\AppData\Local\Temp\phpBA5F.tmp', 'rb')
}
payload = {
    "data": {
        "name": "et",
        "size": 5,
        "things": [
            "et",
            "et"
        ],
        "objects": [
            {
                "a": "et",
                "b": "et"
            }
        ]
    }
}
headers = {
  'Content-Type': 'multipart/form-data',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, files=files, data=payload)
response.json()

require 'rest-client'

body = {
    "data": {
        "name": "et",
        "size": 5,
        "things": [
            "et",
            "et"
        ],
        "objects": [
            {
                "a": "et",
                "b": "et"
            }
        ]
    }
}
headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
}

response = RestClient.post(
    'http://testapi.com/api/nested',
    body ,
    headers
)

p response.body

Request      

POST api/nested

Body Parameters

data  object  

The data

data.name  string  

A string field.

data.size  integer optional  

A number.

data.things  string[] optional  

An array of strings

data.picture  file optional  

A picture.

data.objects  object[] optional  

An array of objects

data.objects[].a  string optional  

A field in the array of objects

data.objects[].b  string optional  

A field in the array of objects

Body content array

Example request:
curl --request POST \
    "http://testapi.com/api/array-body" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "0[row_id]=700" \
    --form "0[name]=My item name" \
    --form "1[row_id]=700" \
    --form "1[name]=My item name" \
    --form "0[picture]=@C:\Users\shalvah\AppData\Local\Temp\phpBA60.tmp" 
const url = new URL(
    "http://testapi.com/api/array-body"
);

const headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('0[row_id]', '700');
body.append('0[name]', 'My item name');
body.append('1[row_id]', '700');
body.append('1[name]', 'My item name');
body.append('0[picture]', document.querySelector('input[name="0[picture]"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://testapi.com/api/array-body',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => '0[row_id]',
                'contents' => '700'
            ],
            [
                'name' => '0[name]',
                'contents' => 'My item name'
            ],
            [
                'name' => '1[row_id]',
                'contents' => '700'
            ],
            [
                'name' => '1[name]',
                'contents' => 'My item name'
            ],
            [
                'name' => '0[picture]',
                'contents' => fopen('C:\Users\shalvah\AppData\Local\Temp\phpBA60.tmp', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/array-body'
files = {
  '0[picture]': open('C:\Users\shalvah\AppData\Local\Temp\phpBA60.tmp', 'rb')
}
payload = [
    {
        "row_id": "700",
        "name": "My item name"
    },
    {
        "row_id": "700",
        "name": "My item name"
    }
]
headers = {
  'Content-Type': 'multipart/form-data',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, files=files, data=payload)
response.json()

require 'rest-client'

body = [
    {
        "row_id": "700",
        "name": "My item name"
    },
    {
        "row_id": "700",
        "name": "My item name"
    }
]
headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
}

response = RestClient.post(
    'http://testapi.com/api/array-body',
    body ,
    headers
)

p response.body

Request      

POST api/array-body

Body Parameters

Body: object[]

List of items

[].row_id  string optional  

A unique ID.

[].name  string  

An element name.

[].picture  file optional  

An optional picture of the element.

File input

Example request:
curl --request POST \
    "http://testapi.com/api/file-input" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "nested[_string]=et" \
    --form "the_file=@C:\Users\shalvah\AppData\Local\Temp\phpBA71.tmp" \
    --form "nested[_file]=@C:\Users\shalvah\AppData\Local\Temp\phpBA72.tmp" 
const url = new URL(
    "http://testapi.com/api/file-input"
);

const headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('nested[_string]', 'et');
body.append('the_file', document.querySelector('input[name="the_file"]').files[0]);
body.append('nested[_file]', document.querySelector('input[name="nested[_file]"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://testapi.com/api/file-input',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'nested[_string]',
                'contents' => 'et'
            ],
            [
                'name' => 'the_file',
                'contents' => fopen('C:\Users\shalvah\AppData\Local\Temp\phpBA71.tmp', 'r')
            ],
            [
                'name' => 'nested[_file]',
                'contents' => fopen('C:\Users\shalvah\AppData\Local\Temp\phpBA72.tmp', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/file-input'
files = {
  'the_file': open('C:\Users\shalvah\AppData\Local\Temp\phpBA71.tmp', 'rb'),
  'nested[_file]': open('C:\Users\shalvah\AppData\Local\Temp\phpBA72.tmp', 'rb')
}
payload = {
    "nested": {
        "_string": "et"
    }
}
headers = {
  'Content-Type': 'multipart/form-data',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, files=files, data=payload)
response.json()

require 'rest-client'

body = {
    "nested": {
        "_string": "et"
    }
}
headers = {
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
}

response = RestClient.post(
    'http://testapi.com/api/file-input',
    body ,
    headers
)

p response.body

Request      

POST api/file-input

Body Parameters

the_file  file  

Just a file.

nested  object  

nested._string  string  

A nested string.

nested._file  file  

A nested file.

General

Healthcheck

Check that the service is up. If everything is okay, you'll get a 200 OK response.

Otherwise, the request will fail with a 400 error, and a response listing the failed services.

Example request:
curl --request GET \
    --get "http://testapi.com/api/healthcheck" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/healthcheck"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://testapi.com/api/healthcheck',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/healthcheck'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.get(
    'http://testapi.com/api/healthcheck',
    headers
)

p response.body

Example response (200):

Show headers
            cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 56
access-control-allow-origin: *
 
            
                

{
    "status": "up",
    "services": {
        "database": "up",
        "redis": "up"
    }
}
 
        

Example response (400, Service is unhealthy):

                

{
    "status": "down",
    "services": {
        "database": "up",
        "redis": "down"
    }
}
 
        

Request      

GET api/healthcheck

Response

Response Fields

status  string  

The status of this API (up or down).

services  object  

Map of each downstream service and their status (up or down).

Side Projects

View all side projects

This endpoint's response was gotten via a "response call"— Scribe called our API in a test environment to get a sample response.

Example request:
curl --request GET \
    --get "http://testapi.com/api/side_projects" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/side_projects"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://testapi.com/api/side_projects',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.get(
    'http://testapi.com/api/side_projects',
    headers
)

p response.body

Example response (200):

Show headers
            cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 54
access-control-allow-origin: *
 
            
                

[
    {
        "id": 1,
        "name": "voluptas assumenda maiores",
        "description": "Consequuntur aut ea est non.",
        "url": null,
        "due_at": "20310222",
        "created_at": "2021-05-30T00:21:59.000000Z",
        "updated_at": "2021-05-30T00:21:59.000000Z",
        "user_id": "2"
    },
    {
        "id": 2,
        "name": "iusto ut dolor",
        "description": "Voluptatem aspernatur dolorem quae quaerat harum.",
        "url": null,
        "due_at": "20301215",
        "created_at": "2021-05-30T00:21:59.000000Z",
        "updated_at": "2021-05-30T00:21:59.000000Z",
        "user_id": "1"
    },
    {
        "id": 3,
        "name": "provident et consequatur",
        "description": "Quos et ipsum cum pariatur ex perspiciatis eius.",
        "url": null,
        "due_at": "20231022",
        "created_at": "2021-05-30T00:23:25.000000Z",
        "updated_at": "2021-05-30T00:23:25.000000Z",
        "user_id": "3"
    },
    {
        "id": 4,
        "name": "corporis consequuntur amet",
        "description": "Dolores eveniet deleniti voluptatem saepe expedita.",
        "url": null,
        "due_at": "20230712",
        "created_at": "2021-05-30T00:23:25.000000Z",
        "updated_at": "2021-05-30T00:23:25.000000Z",
        "user_id": "1"
    },
    {
        "id": 5,
        "name": "optio excepturi ea",
        "description": "Error deleniti sint a nostrum consequuntur et.",
        "url": null,
        "due_at": "20260324",
        "created_at": "2021-05-30T00:24:27.000000Z",
        "updated_at": "2021-05-30T00:24:27.000000Z",
        "user_id": "4"
    },
    {
        "id": 6,
        "name": "nihil voluptate quaerat",
        "description": "Animi reprehenderit soluta id quo.",
        "url": null,
        "due_at": "20290603",
        "created_at": "2021-05-30T00:24:27.000000Z",
        "updated_at": "2021-05-30T00:24:27.000000Z",
        "user_id": "1"
    },
    {
        "id": 7,
        "name": "aspernatur architecto assumenda",
        "description": "Nisi ea aut vel sint vero voluptas tempore.",
        "url": null,
        "due_at": "20280710",
        "created_at": "2021-05-30T00:25:43.000000Z",
        "updated_at": "2021-05-30T00:25:43.000000Z",
        "user_id": "5"
    },
    {
        "id": 8,
        "name": "vel perspiciatis quo",
        "description": "Et qui praesentium consequatur distinctio natus.",
        "url": null,
        "due_at": "20210605",
        "created_at": "2021-05-30T00:25:43.000000Z",
        "updated_at": "2021-05-30T00:25:43.000000Z",
        "user_id": "1"
    },
    {
        "id": 9,
        "name": "qui et totam",
        "description": "Veritatis quo dolorum soluta ut.",
        "url": null,
        "due_at": "20270203",
        "created_at": "2021-05-30T00:25:43.000000Z",
        "updated_at": "2021-05-30T00:25:43.000000Z",
        "user_id": "1"
    }
]
 
        

Request      

GET api/side_projects

Start a new side project

requires authentication

Even though we both know you'll never finish it.

This endpoint's body parameters were automatically generated by Scribe from the controller's code. Check out the source!

Example request:
curl --request POST \
    "http://testapi.com/api/side_projects" \
    --header "Authorization: Bearer {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"The SideProject API\",
    \"description\": \"pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv\",
    \"url\": \"http:\\/\\/hartmann.com\\/magnam-tenetur-quia-nemo-sit-est-numquam\",
    \"due_at\": \"2082-12-20\"
}"
const url = new URL(
    "http://testapi.com/api/side_projects"
);

const headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "The SideProject API",
    "description": "pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv",
    "url": "http:\/\/hartmann.com\/magnam-tenetur-quia-nemo-sit-est-numquam",
    "due_at": "2082-12-20"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://testapi.com/api/side_projects',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Accept' => 'application/json',
        ],
        'json' => [
            'name' => 'The SideProject API',
            'description' => 'pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv',
            'url' => 'http://hartmann.com/magnam-tenetur-quia-nemo-sit-est-numquam',
            'due_at' => '2082-12-20',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects'
payload = {
    "name": "The SideProject API",
    "description": "pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv",
    "url": "http:\/\/hartmann.com\/magnam-tenetur-quia-nemo-sit-est-numquam",
    "due_at": "2082-12-20"
}
headers = {
  'Authorization': 'Bearer {YOUR_AUTH_KEY}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

require 'rest-client'

body = {
    "name": "The SideProject API",
    "description": "pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv",
    "url": "http:\/\/hartmann.com\/magnam-tenetur-quia-nemo-sit-est-numquam",
    "due_at": "2082-12-20"
}
headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.post(
    'http://testapi.com/api/side_projects',
    body ,
    headers
)

p response.body

Request      

POST api/side_projects

Body Parameters

name  string  

The name of your side project. Must not be greater than 80 characters.

description  string optional  

A longer description of your side project. Must not be greater than 255 characters.

url  string optional  

A url to your side project. Must be a valid URL.

due_at  string optional  

Due date for the side project. Must be a valid date. Must be a valid date in the format Ymd. Must be a date after today.

View a side project

This endpoint's response uses a Fractal transformer, so we tell Scribe that using an annotation, and it figures out how to generate a sample. The 404 sample is gotten from a "response file".

Example request:
curl --request GET \
    --get "http://testapi.com/api/side_projects/13" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/side_projects/13"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://testapi.com/api/side_projects/13',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects/13'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.get(
    'http://testapi.com/api/side_projects/13',
    headers
)

p response.body

Example response (200):

                

{
    "data": {
        "name": "suscipit qui cumque",
        "description": "Tenetur quia nemo sit est.",
        "due_date": "20230829",
        "owner": {
            "id": 1,
            "name": "Pete",
            "email": "pete@home.com",
            "email_verified_at": null,
            "created_at": "2021-05-29T22:53:05.000000Z",
            "updated_at": "2021-05-29T22:53:05.000000Z"
        }
    }
}
 
        

Request      

GET api/side_projects/{id}

URL Parameters

id  integer  

The ID of the side project.

Update a side project

Example request:
curl --request PUT \
    "http://testapi.com/api/side_projects/13" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/side_projects/13"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "PUT",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->put(
    'http://testapi.com/api/side_projects/13',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects/13'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.put(
    'http://testapi.com/api/side_projects/13',
    headers
)

p response.body

Request      

PUT api/side_projects/{id}

PATCH api/side_projects/{id}

URL Parameters

id  integer  

The ID of the side project.

Delete a side project

Example request:
curl --request DELETE \
    "http://testapi.com/api/side_projects/13" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/side_projects/13"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->delete(
    'http://testapi.com/api/side_projects/13',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects/13'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.delete(
    'http://testapi.com/api/side_projects/13',
    headers
)

p response.body

Request      

DELETE api/side_projects/{id}

URL Parameters

id  integer  

The ID of the side project.

Users

Create a user

This endpoint's body parameters are automatically generated from a FormRequest.

Example request:
curl --request POST \
    "http://testapi.com/api/users" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv\",
    \"email\": \"casimir70@example.com\",
    \"password\": \"et\"
}"
const url = new URL(
    "http://testapi.com/api/users"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv",
    "email": "casimir70@example.com",
    "password": "et"
}

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://testapi.com/api/users',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'json' => [
            'name' => 'pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv',
            'email' => 'casimir70@example.com',
            'password' => 'et',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/users'
payload = {
    "name": "pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv",
    "email": "casimir70@example.com",
    "password": "et"
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

require 'rest-client'

body = {
    "name": "pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv",
    "email": "casimir70@example.com",
    "password": "et"
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.post(
    'http://testapi.com/api/users',
    body ,
    headers
)

p response.body

Request      

POST api/users

Body Parameters

name  string  

Must be at least 1 characters. Must not be greater than 255 characters.

email  string  

Must be a valid email address.

password  string  

Fetch a user

This endpoint's response uses an Eloquent API resource, so we tell Scribe that using an annotation, and it figures out how to generate a sample. The 404 sample is gotten from a "response file".

Example request:
curl --request GET \
    --get "http://testapi.com/api/users/13" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/users/13"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://testapi.com/api/users/13',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/users/13'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.get(
    'http://testapi.com/api/users/13',
    headers
)

p response.body

Example response (200):

                

{
    "data": {
        "id": 6,
        "name": "Mr. Merlin Friesen",
        "email": "hdoyle@example.com",
        "side_projects": [
            {
                "id": 10,
                "name": "est numquam consequuntur",
                "description": "Atque nobis ut natus aut dolores eveniet.",
                "url": null,
                "due_at": "20241013",
                "created_at": "2021-07-02T13:13:46.000000Z",
                "updated_at": "2021-07-02T13:13:46.000000Z",
                "user_id": "6"
            }
        ]
    }
}
 
        

Example response (404, User not found):

                

{
    "message": "Not found",
    "resource": "user"
}
 
        

Request      

GET api/users/{id}

URL Parameters

id  integer  

The ID of the user.

View all users

This endpoint uses a custom Scribe strategy that parses a @usesPagination annotation to add some query parameters.

The sample response is gotten by Scribe making a test API call (aka "response call").

Example request:
curl --request GET \
    --get "http://testapi.com/api/users?page=1" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/users"
);

const params = {
    "page": "1",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://testapi.com/api/users',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
        'query' => [
            'page'=> '1',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/users'
params = {
  'page': '1',
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.get(
    'http://testapi.com/api/users',
    headers
)

p response.body

Example response (200):

Show headers
            cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 55
access-control-allow-origin: *
 
            
                

{
    "data": [
        {
            "id": 1,
            "name": "Pete",
            "email": "pete@home.com",
            "side_projects": [
                {
                    "id": 2,
                    "name": "iusto ut dolor",
                    "description": "Voluptatem aspernatur dolorem quae quaerat harum.",
                    "url": null,
                    "due_at": "20301215",
                    "created_at": "2021-05-30T00:21:59.000000Z",
                    "updated_at": "2021-05-30T00:21:59.000000Z",
                    "user_id": "1"
                },
                {
                    "id": 4,
                    "name": "corporis consequuntur amet",
                    "description": "Dolores eveniet deleniti voluptatem saepe expedita.",
                    "url": null,
                    "due_at": "20230712",
                    "created_at": "2021-05-30T00:23:25.000000Z",
                    "updated_at": "2021-05-30T00:23:25.000000Z",
                    "user_id": "1"
                },
                {
                    "id": 6,
                    "name": "nihil voluptate quaerat",
                    "description": "Animi reprehenderit soluta id quo.",
                    "url": null,
                    "due_at": "20290603",
                    "created_at": "2021-05-30T00:24:27.000000Z",
                    "updated_at": "2021-05-30T00:24:27.000000Z",
                    "user_id": "1"
                },
                {
                    "id": 8,
                    "name": "vel perspiciatis quo",
                    "description": "Et qui praesentium consequatur distinctio natus.",
                    "url": null,
                    "due_at": "20210605",
                    "created_at": "2021-05-30T00:25:43.000000Z",
                    "updated_at": "2021-05-30T00:25:43.000000Z",
                    "user_id": "1"
                },
                {
                    "id": 9,
                    "name": "qui et totam",
                    "description": "Veritatis quo dolorum soluta ut.",
                    "url": null,
                    "due_at": "20270203",
                    "created_at": "2021-05-30T00:25:43.000000Z",
                    "updated_at": "2021-05-30T00:25:43.000000Z",
                    "user_id": "1"
                }
            ]
        },
        {
            "id": 2,
            "name": "Alexane Weber",
            "email": "lacy.wintheiser@example.net",
            "side_projects": [
                {
                    "id": 1,
                    "name": "voluptas assumenda maiores",
                    "description": "Consequuntur aut ea est non.",
                    "url": null,
                    "due_at": "20310222",
                    "created_at": "2021-05-30T00:21:59.000000Z",
                    "updated_at": "2021-05-30T00:21:59.000000Z",
                    "user_id": "2"
                }
            ]
        },
        {
            "id": 3,
            "name": "John Kshlerin II",
            "email": "titus77@example.com",
            "side_projects": [
                {
                    "id": 3,
                    "name": "provident et consequatur",
                    "description": "Quos et ipsum cum pariatur ex perspiciatis eius.",
                    "url": null,
                    "due_at": "20231022",
                    "created_at": "2021-05-30T00:23:25.000000Z",
                    "updated_at": "2021-05-30T00:23:25.000000Z",
                    "user_id": "3"
                }
            ]
        },
        {
            "id": 4,
            "name": "Rebeca Morissette",
            "email": "cole.geoffrey@example.com",
            "side_projects": [
                {
                    "id": 5,
                    "name": "optio excepturi ea",
                    "description": "Error deleniti sint a nostrum consequuntur et.",
                    "url": null,
                    "due_at": "20260324",
                    "created_at": "2021-05-30T00:24:27.000000Z",
                    "updated_at": "2021-05-30T00:24:27.000000Z",
                    "user_id": "4"
                }
            ]
        },
        {
            "id": 5,
            "name": "Prof. Adah Witting IV",
            "email": "nswift@example.net",
            "side_projects": [
                {
                    "id": 7,
                    "name": "aspernatur architecto assumenda",
                    "description": "Nisi ea aut vel sint vero voluptas tempore.",
                    "url": null,
                    "due_at": "20280710",
                    "created_at": "2021-05-30T00:25:43.000000Z",
                    "updated_at": "2021-05-30T00:25:43.000000Z",
                    "user_id": "5"
                }
            ]
        }
    ]
}
 
        

Request      

GET api/users

Query Parameters

page  string optional  

Page number to return.

pageSize  string optional  

Number of items to return in a page. Defaults to 10.

Authenticate

Get a new API token.

Example request:
curl --request POST \
    "http://testapi.com/api/users/13/auth" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/users/13/auth"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://testapi.com/api/users/13/auth',
    [
        'headers' => [
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/users/13/auth'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers)
response.json()

require 'rest-client'

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
}

response = RestClient.post(
    'http://testapi.com/api/users/13/auth',
    headers
)

p response.body

Example response (200):

                

{
    "token": "2|KLDoUXc68Ko0JaFDZoX9qYkUqWglwdGxQsvTGBCg"
}
 
        

Request      

POST api/users/{id}/auth

URL Parameters

id  integer  

The ID of the user.

Response

Response Fields

token  string  

The new API token. Valid forever.