MENU navbar-image

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

Just a heading

With stuff under

And then another!

These headings were added by editing .scribe/intro.md

Authenticating requests

To authenticate requests, include an Authorization header with the value "Bearer {BEARER_TOKEN}".

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

Another subgroup

This time, with a description!

GET api/v1/languages

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

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

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

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

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

require 'rest-client'

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

response = RestClient.get(
    'http://testapi.com/api/v1/languages',
    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: *
 

[]
 

Request      

GET api/v1/languages

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\phpEDB6.tmp" \
    --form "nested[_file]=@C:\Users\shalvah\AppData\Local\Temp\phpEDB7.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' => [
            'Content-Type' => 'multipart/form-data',
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'nested[_string]',
                'contents' => 'et'
            ],
            [
                'name' => 'the_file',
                'contents' => fopen('C:\Users\shalvah\AppData\Local\Temp\phpEDB6.tmp', 'r')
            ],
            [
                'name' => 'nested[_file]',
                'contents' => fopen('C:\Users\shalvah\AppData\Local\Temp\phpEDB7.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\phpEDB6.tmp', 'rb'),
  'nested[_file]': open('C:\Users\shalvah\AppData\Local\Temp\phpEDB7.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.

A subgroup

Nested fields

Example request:
curl --request POST \
    "http://testapi.com/api/nested?random=et" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"data\": {
        \"name\": \"et\",
        \"size\": 5,
        \"things\": [
            \"et\"
        ],
        \"objects\": [
            {
                \"a\": \"et\",
                \"b\": \"et\"
            }
        ]
    }
}"
const url = new URL(
    "http://testapi.com/api/nested"
);

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

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

let body = {
    "data": {
        "name": "et",
        "size": 5,
        "things": [
            "et"
        ],
        "objects": [
            {
                "a": "et",
                "b": "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/nested',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'random'=> 'et',
        ],
        'json' => [
            'data' => [
                'name' => 'et',
                'size' => 5,
                'things' => [
                    'et',
                ],
                'objects' => [
                    [
                        'a' => 'et',
                        'b' => 'et',
                    ],
                ],
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/nested'
payload = {
    "data": {
        "name": "et",
        "size": 5,
        "things": [
            "et"
        ],
        "objects": [
            {
                "a": "et",
                "b": "et"
            }
        ]
    }
}
params = {
  'random': 'et',
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

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

require 'rest-client'

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

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

p response.body

Request      

POST api/nested

Query Parameters

random   string  optional  

A random query parameter.

Body Parameters

data   object   

The data

data.name   string   

A string field.

data.size   integer  optional  

A number.

data.other   string  optional  

Optional thing.

data.things   string[]  optional  

An array of strings.

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: application/json" \
    --header "Accept: application/json" \
    --data "[
    {
        \"row_id\": \"700\",
        \"name\": \"My item name\"
    }
]"
const url = new URL(
    "http://testapi.com/api/array-body"
);

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

let body = [
    {
        "row_id": "700",
        "name": "My item name"
    }
];

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://testapi.com/api/array-body',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            [
                'row_id' => '700',
                'name' => 'My item name',
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/array-body'
payload = [
    {
        "row_id": "700",
        "name": "My item name"
    }
]
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

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

require 'rest-client'

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

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

p response.body

Request      

POST api/array-body

Body Parameters

The request body is an array (object[]`), representing list of items.

[].row_id   string  optional  

A unique ID.

[].name   string   

An element name.

Other

I added this endpoint by creating a custom.0.yaml file in .scribe. See the docs.

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

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/oooooi',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/oooooi'
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/oooooi',
    headers
)

p response.body

Example response (When the thing was done smoothly.):


{
    "hey": "ho ho ho"
}
 

Example response (Just for fun.):


{
    "hey": "ho"
}
 

Example response (Even more fun!):

[Empty response]
 

Request      

POST api/oooooi

Response

Response Fields

hey   string   

Who knows?

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/et" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/healthcheck/et"
);

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/et',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/healthcheck/et'
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/et',
    headers
)

p response.body

Example response (400, Service is unhealthy):


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

Example response (200):

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

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

Request      

GET api/healthcheck/{unnecessaryParam?}

URL Parameters

unnecessaryParam   string  optional  

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).

GET api/me

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

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/me',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/me'
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/me',
    headers
)

p response.body

Example response (401):

Show headers
cache-control: no-cache, private
content-type: application/json
access-control-allow-origin: *
 

{
    "message": "Unauthenticated."
}
 

Request      

GET api/me

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' => [
            'Content-Type' => 'application/json',
            '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/1" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/users/1"
);

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/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/users/1'
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/1',
    headers
)

p response.body

Example response (404, User not found):


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

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": 20251222,
                "created_at": "2022-09-10T02:22:36.000000Z",
                "updated_at": "2022-09-10T02:22:36.000000Z",
                "user_id": 6
            }
        ]
    }
}
 

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' => [
            'Content-Type' => 'application/json',
            '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: 58
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. This parameter was added by a custom strategy.

pageSize   string  optional  

Number of items to return in a page. Defaults to 10. This parameter was added by a custom strategy.

Delete a user

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

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

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/users/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'confirm'=> 'true',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

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

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

require 'rest-client'

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

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

p response.body

Example response (200):


You've fucked up now!
 

Request      

DELETE api/users/{id}

URL Parameters

id   integer   

The ID of the user.

Query Parameters

confirm   string  optional  

A really silly parameter

Authenticate

Get a new API token.

Example request:
curl --request POST \
    "http://testapi.com/api/users/1/auth" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/users/1/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/1/auth',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/users/1/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/1/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.

Side Projects

APIs for managing side projects.

Note how the URL params for the endpoints here are automatically generated by Scribe.

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 {BEARER_TOKEN}" \
    --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\": \"2084-02-27\"
}"
const url = new URL(
    "http://testapi.com/api/side_projects"
);

const headers = {
    "Authorization": "Bearer {BEARER_TOKEN}",
    "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": "2084-02-27"
};

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 {BEARER_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'name' => 'The SideProject API',
            'description' => 'pidsgyfhasfdpmrgozmxiqtrcoqjruexeugqpersioudgkpsbnkltlaqvmwjyiahevihxmbowbowymkwgcqxiqmrchyclplgrcipefeeopzzxuuljqvytlucrlnslwwcdxrknhwrlmabpwubvoetriefhfwzv',
            'url' => 'http://hartmann.com/magnam-tenetur-quia-nemo-sit-est-numquam',
            'due_at' => '2084-02-27',
        ],
    ]
);
$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": "2084-02-27"
}
headers = {
  'Authorization': 'Bearer {BEARER_TOKEN}',
  '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": "2084-02-27"
}
headers = {
    "Authorization": "Bearer {BEARER_TOKEN}",
    "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 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' => [
            'Content-Type' => 'application/json',
            '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: 57
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

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".

Also, this endpoint uses a mix of docblock tags and PHP 8 attributes.

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

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/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects/1'
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/1',
    headers
)

p response.body

Example response (203):


{
    "data": {
        "name": "suscipit qui cumque",
        "description": "Tenetur quia nemo sit est.",
        "due_date": "20241106",
        "owner": {
            "id": 6,
            "name": "Kurt Kub",
            "email": "juvenal97@example.org",
            "email_verified_at": "2022-09-10T02:22:36.000000Z",
            "created_at": "2022-09-10T02:22:36.000000Z",
            "updated_at": "2022-09-10T02:22:36.000000Z"
        }
    }
}
 

Example response (404, Side project not found):


{
    "message": "Not found",
    "resource": "Side project"
}
 

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/1" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/side_projects/1"
);

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/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects/1'
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/1',
    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/1" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://testapi.com/api/side_projects/1"
);

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/1',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects/1'
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/1',
    headers
)

p response.body

Example response (204, Nothing to see here):

[Empty response]
 

Example response (An extra, for fun.):



 

Request      

DELETE api/side_projects/{id}

URL Parameters

id   integer   

The ID of the side project.

Query Parameters

queryThing   string  optional  

Finish a side project

Will you ever?🤔

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

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/side_projects/finish',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/side_projects/finish'
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/side_projects/finish',
    headers
)

p response.body

Example response (Side project not found):


{
    "message": "Not found",
    "resource": "Side project"
}
 

Request      

POST api/side_projects/finish

Extras

A custom endpoint

I added this endpoint by creating a custom.0.yaml file in .scribe. See the docs.

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

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/aCustomEndpoint',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://testapi.com/api/aCustomEndpoint'
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/aCustomEndpoint',
    headers
)

p response.body

Example response (When the thing was done smoothly.):


{
    "hey": "ho ho ho"
}
 

Example response (Just for fun.):


{
    "hey": "ho"
}
 

Example response (Even more fun!):

[Empty response]
 

Request      

POST api/aCustomEndpoint

Response

Response Fields

hey   string   

Who knows?

A custom 2

Example request:
curl --request POST \
    "http://testapi.com/api/aCustomEndpoint"
const url = new URL(
    "http://testapi.com/api/aCustomEndpoint"
);

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

url = 'http://testapi.com/api/aCustomEndpoint'
response = requests.request('POST', url, )
response.json()

require 'rest-client'

response = RestClient.post(
    'http://testapi.com/api/aCustomEndpoint')

p response.body

Request      

POST api/aCustomEndpoint