Managing APIs via the REST Platform API
How to use the Platform API to create and update APIs in your Enterprise Hub
To get started creating, updating, or deleting APIs via the Platform API, navigate to the Platform API listing. You can create and update APIs directly through the Platform API listing, or copy the code snippet generated by the API listing to call the API from your application.
Create an API by uploading an OAS document with RapidAPI Extensions
To create an API by uploading an OAS document with RapidAPI extensions , use one of the following two endpoints:
- Create API with RapidAPI OpenApi metadata file
- Create API with RapidAPI OpenApi metadata file (Environment Admin)
Use the second endpoint above if you have environment admin access to the Platform API and want to create an API on behalf of another entity. If you use the second endpoint above, you must specify either the team's ID or user's ID that will own the API in the ownerId field of the request body.
The following is sample Node.js code that you can use as a starting point to create an API using the second endpoint above.
//REPLACE THE FOLLOWING WITH YOUR VALUES
const OWNERID = '5713300';
const FILENAME = 'openapi.json';
const URL = 'https://platformv.p.rapidapi.com/v1/apis/rapidapi-file/admin';
const HOST = 'platformapi1.rapidapi-x.rapidapi.com';
const KEY = '4dbbxxxx';
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const formData = new FormData();
formData.append('ownerId', OWNERID);
let file = fs.readFileSync(FILENAME);
// MODIFY OAS DOCUMENT HERE
file = JSON.parse(file);
//file.info['x-category'] = 'Other';
file = JSON.stringify(file);
formData.append('file', file, FILENAME);
axios.post(URL, formData, {
headers: {
...formData.getHeaders(),
'Content-Length': formData.getLengthSync(),
'x-rapidapi-host': HOST,
'x-rapidapi-key': KEY
}
}).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error.response.data);
});
Create an API
To create an API via the Platform API (assuming you are not uploading an OAS document with RapidAPI Extensions as described above), navigate to the APIS endpoint group and select the Create API endpoint. Complete the following steps:
-
Select the proper account context. If you aren't sure what this means, learn more about account contexts here.
-
Select the desired RapidAPI App and Request URL from the dropdowns.
-
Fill out the request body:
fileFormat
: Specify the file type.file
: Upload an OpenAPI Specification.
File Upload
Note that if you choose to upload an OpenAPI file, this data will over-ride other information provided in the call. For example, if the OpenAPI file contains a description, this will be used when the API is created regardless of the description you provide in the request body.
name
: The API name. Note: Do not include the term "API" in the name, because it will lead to redundancy. In the example above, we named the API "Docs Demo" but it appears as "Docs Demo API". If we named it "Docs Demo API" it would appear as "Docs Demo API API" on the API Listing.description
: The description appears on the API Listing on the "Endpoints" tab. Typically, this is used to summarize the API in a few sentences.imageFile
: This image appears as the API's icon on the API Listing and other locations that show the API Name and image, such as the Organization Homepage or the Marketplace. Recommended image size 500x500 px, PNG or JPG formats are supported.category
: Select a category for the API. The category must already exist in the Enterprise Hub.
websiteUrl
: A link to the website that provides the API. Appears on the "About" tab.longDescription
: The long description appears on the API Listing on the "About" tab. Typically, this is used to provide more detailed information about the API, use cases, or other documentation.tos
: Terms of service for using the API (if applicable).
-
Click "Test Endpoint" to call the API from your browser, or copy the code snippet to call the API from your application.
-
You will see a 201 status code if the call is successful and the API is created.
Update an API by uploading an OAS document with RapidAPI Extensions
To create an API by uploading an OAS document with RapidAPI extensions , use one of the following two endpoints:
- Update API with RapidAPI OpenApi metadata file
- Update API with RapidAPI OpenApi metadata file (Environment Admin)
Use the second endpoint above if you have environment admin access to the Platform API and want to update an API on behalf of another entity. If you use the second endpoint above, you must specify either the team's ID or user's ID that owns the API in the ownerId field of the request body. You must also specify the apiId and versionId of the API that you are updating.
The following is sample Node.js code that you can use as a starting point to update an API using the second endpoint above.
//REPLACE THE FOLLOWING WITH YOUR VALUES
const OWNERID = '5713300';
const FILENAME = 'openapi update.json';
const APIID = 'api_70cb056c-xx';
const VERSIONID = 'apiversion_7bfxx'
const URL = 'https://platformapi1.p.rapidapi.com/v1/apis/rapidapi-file/admin/' + APIID + '/versions/' + VERSIONID;
const HOST = 'platformapi1.rapidapi-x.rapidapi.com';
const KEY = '4dbb6bxx';
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const formData = new FormData();
formData.append('ownerId', OWNERID);
let file = fs.readFileSync(FILENAME);
// MODIFY OAS DOCUMENT HERE
file = JSON.parse(file);
//file.info['x-category'] = 'Other';
file = JSON.stringify(file);
formData.append('file', file, FILENAME);
axios.put(URL, formData, {
headers: {
...formData.getHeaders(),
'Content-Length': formData.getLengthSync(),
'x-rapidapi-host': HOST,
'x-rapidapi-key': KEY
}
}).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error.response.data);
});
Update an API
Once you create an API, you can update it using the RapidAPI UI or the Platform API.
To update an API via the Platform API (assuming you are not uploading an OAS document with RapidAPI Extensions as described above), navigate to the APIS endpoint group and select the Update API endpoint. Complete the following steps:
-
Select the proper account context. If you aren't sure what this means, learn more about account contexts here.
-
Select the desired RapidAPI App and Request URL from the dropdowns.
-
Fill out the required parameters and request body:
apiId
: The API ID is a unique identifier for the API. You can get this value from the Admin Panel or by using the GET All APIs endpoint of the Platform API.
Please note, that in order to update an API that you're not an owner of, you will need to have Environment Admin Access to the Platform API and initiate the request on-behalf-of another user.
fileFormat
: Specify the file type.file
: Upload an OpenAPI Specification.name
: The API name. Note: Do not include the term "API" in the name, because it will lead to redundancy.visibility
: Set the API visibility to public or private. If private, only the API owner and developer who are invited to the API will be able to use and view the API.description
: The description appears on the API Listing on the "Endpoints" tab. Typically, this is used to summarize the API in a few sentences.imageFile
: This image appears as the API's icon on the API Listing and other locations that show the API Name and image, such as the Organization Homepage or the Marketplace. Recommended image size 500x500 px, PNG or JPG formats are supported.category
: Select a category for the API. The category must already exist in the Enterprise Hub.websiteUrl
: A link to the website that provides the API. Appears on the "About" tab.longDescription
: The long description appears on the API Listing on the "About" tab. Typically, this is used to provide more detailed information about the API, use cases, or other documentation.
-
Click "Test Endpoint" to call the API from your browser, or copy the code snippet to call the API from your application.
-
You will see a 200 status code if the call is successful and the API is updated.
Delete an API
To delete an API via the Platform API, navigate to the APIS endpoint group and select the Delete API endpoint. Complete the following steps:
-
Select the proper account context. If you aren't sure what this means, learn more about account contexts here.
-
Select the desired RapidAPI App and Request URL from the dropdowns.
-
Fill out the required parameters:
apiId
: The API ID is a unique identifier for the API. You can get this value from the Admin Panel or by using the GET All APIs endpoint of the Platform API.
-
Click "Test Endpoint" to call the API from your browser, or copy the code snippet to call the API from your application.
-
You will see a 204 status code if the call is successful and the API is deleted.
Deleting an API is permanent
Deleting an API can NOT be undone. Please proceed with caution.
You will lose all of the:
- API subscriptions
- API data and analytics
- API documentation
Updated 11 months ago