Register your endpoint by posting to mocit. Mocit will return the path to call.
POST: https://mocit.p.rapidapi.com/v1/mocit
Status: 200
Response:
{
"base_path": "https://mocit.p.rapidapi.com/v1/service",
"expiration": "2023-08-27 14:45:48 UTC",
"full_path": "https://mocit.p.rapidapi.com/v1/service/food/fruit",
"method": "GET",
"name": "Food Service",
"path": "/food/fruit"
}
Call your endpoint and process the response.
GET: https://mocit.p.rapidapi.com/v1/service/food/fruit
Status: 200
Response:
{
"fruit":"grape"
}
import requests
HEADERS = {
"X-RapidAPI-Key": "YOUR RAPID API KEY",
"X-RapidAPI-Host": "mocit.p.rapidapi.com"
}
# Step 1 - Register your mock service on mocit
MOCK_RESPONSE = {
'name':'Food Service',
'path':'/food/fruit',
'method':'get',
'status_code':200,
'delay':0,
'response_body':{
"fruit":"grape"
}
}
url = "https://mocit.p.rapidapi.com/v1/mocit"
response = requests.post(url, headers=HEADERS, json=MOCK_RESPONSE)
mock_path = response.json()['full_path']
# mock_path = "https://mocit.p.rapidapi.com/v1/service/food/fruit"
# Step 2 - Call your mock service and process the response
response = requests.get(url=mock_path, headers=HEADERS, json={"testing":"fruit"})
print("%d: %s"%(response.status_code, response.json()))