Mock APIs
This is documentation for the Mock APIs admin page in RequestBite HQ.
Add new mock API
To add a new mock API, do like this:
- Click the blue Add API button in the upper right corner.
- In the dialog that appears, provide the following:
- Name of mock API (optional)
Name your API. It will be called Untitled mock API #n if left blank. - Base URL (Optiona)
The root URL of your mock API will behttps://m.requestbite.com. If you append a base URL to your API, you can add it here. Common examples could be/apior/api/v1. Leave empty if you don't want a base URL.
- Name of mock API (optional)
- Click Create.
You now have an (empty) API and if you click ... in the far right column next to your API , you will see a dropdown with a number of actions you can perform, such as copying the base URL or downloading a OpenAPI definition.
Test your mock API
You can now test your new API like so:
In the ... dropdown, click _Copy cURL command. This will copy a fully working cURL command to your clipboard with the necessary credentials to call your newly created mock API.
Paste what you got into your Bash terminal and append | jq at the end:
curl -X GET -H 'Authorization: Bearer {token}' https://m.requestbite.com | jq
jq is used to format the response. You can safely remove | jq from the command above if you don't have it installed.
When you hit Enter, you should have a response like this:
{
"info": "Welcome to the RequestBite mock API called \"<your-api-name-here>\".",
"endpoints": []
}
This means your mock API is up and running. Now you're ready to add some endpoints.
Download OpenAPI definition
RequestBite supports generating an OpenAPI 3.1 definition file for your API.
OpenAPI is a format describing REST APIs, and the resulting file can e.g. be imported into API clients such as Slingshot so you can quickly start using your mock API, or they can be used with various tools to create source code stubs. An extensive list of tools that support OpenAPI can be found here.
To download your OpenAPI definition, click ... and select Download OpenAPI.
A file called <your-api-name>.yaml will now be downloaded to your computer.
Import OpenAPI into Slingshot
There are two menu items in the ... context menu that are disabled by default:
- Open OpenAPI spec
- Open OpenAPI in Slingshot
This is because to use these options you must make your OpenAPI spec publicly available (Slingshot can of course open your already downloaded spec, but if you want to open it directly from your RequestBite account, it must be public).
To make your OpenAPI spec public, click the name of your API and in the edit view click the checkbox Make OpenAPI spec public.
Now you can import the spec directly to Slingshot by selecting Open OpenAPI in Slingshot in the context menu.
Delete mock API
Deleting a mock API also associates any related endpoints. Deleting a mock API does not delete any used models, however. To delete a mock API, do like this:
- Open the API's context menu by clicking
...at the far right. - Select Delete API... in the menu.
- Confirm the deletion by clicking Delete API in the modal that appears.