Sample APIs
Welcome to SampleAPIs. A playground for messing with RESTful endpoints.
You can use any HTTP verbs (GET, POST, PUT, PATCH and DELETE).* The data on this site will be reset on a regular basis.
Getting an API key
You can always simply browse the data in these APIs using the endpoints provided.
HOWEVER, if you want to add/remove/change data, and view that changed data reflected in the endpoints, you will need an API key.
To get an API key, you will need to go to /token?email= and add your AP Hogeschool email adress in the request. This will provide you with a unique API key to use in your requests.
To use your API key, you will need to add it as a bearer token. A bearer token can be included in a request by adding an Authorization request header with the prefix "Bearer"
example code:
Copied!
// auth header with bearer token
const headers = { 'Authorization': 'Bearer my-token' };
const baseURL = "https://sampleapis.assimilate.be/futurama/characters/";
fetch(baseURL, {headers})
.then(resp => resp.json())
.then(data => console.log(data));
GET requests
To retrieve data from an endpoint, you only need a bearer token if you want to retrieve data you have changed (using the same bearer token).
example code:
Copied!
const headers = { 'Authorization': 'Bearer my-token' };
const baseURL = "https://sampleapis.assimilate.be/futurama/characters/";
fetch(baseURL, {headers})
.then(resp => resp.json())
.then(data => console.log(data));
Want to Search? Then use this endpoint:
Copied!
const headers = { 'Authorization': 'Bearer my-token' };
const baseURL = "https://sampleapis.assimilate.be/futurama/characters/";
fetch(`${baseURL}?name.first=Bender`, {headers})
.then(resp => resp.json())
.then(data => console.log(data));
POST requests
To add data to an endpoint, you NEED to use a bearer token. Otherwise, your request gets denied.
Copied!
const headers = { method: 'POST', 'Authorization': 'Bearer my-token' };
const baseURL = "https://sampleapis.assimilate.be/futurama/characters/";
fetch(baseURL, {headers})
.then(resp => resp.json())
.then(data => console.log(data));