🖊️Calling APIs on Blockflow
Once you have created an API on Blockflow, you can invoke it using the following endpoint formats:
Using API ID:
Using API Slug and Project ID:
API ID and Project ID
You can find the apiId
and projectId
on your Blockflow dashboard. These identifiers are unique to each API and project, respectively.
apiId
: The unique identifier assigned to your API.projectId
: The unique identifier assigned to your project.
API Slug
The apiSlug
is a user-defined, URL-friendly name for your API. You specify the API slug during the API creation process. It allows you to use a more descriptive and meaningful name in the API endpoint URL.
Examples
Let's say you have an API with the following details:
API ID: "123"
Project ID: "456"
API Slug: "test"
You can call the API using either of the following endpoints:
Using API ID:
Using API Slug and Project ID:
Authentication
When calling your API, make sure to include the necessary authentication credentials as specified in your API configuration. This will include API keys, tokens, or other authentication mechanisms.
Query Parameters and Request Body
Depending on your API design, you may need to pass additional query parameters or include a request body when making API calls. Refer to this guide to understand the required parameters and request format.
🖊️How to write API logicsError Handling
If an error occurs while calling your API, Blockflow will return an appropriate HTTP status code along with an error message in the response body.
API Documentation
To provide a better developer experience, it's recommended to document your API endpoints, request/response formats, and any authentication requirements. You can use tools like Swagger or Postman to create and host your API documentation.
Example API Call
Here's an example of making an API call to your Blockflow API using JavaScript and the Fetch API: