Ana içeriğe geç

Get Mock API

Endpoint​

GET /apiops/projects/{projectName}/mockapis/{mockApiName}/

Authentication​

Requires a Personal API Access Token.

Authorization: Bearer YOUR_TOKEN

Request​

Headers​

HeaderValueRequired
AuthorizationBearer {token}Yes

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
mockApiNamestringYesMock API name

Response​

Success Response (200 OK)​

The requested Mock API is returned as the single element of resultList. The example below is shortened.

{
"status": "SUCCESS",
"resultList": [
{
"id": "66f1c0a2e4b0a1b2c3d4e5f6",
"name": "Customer Accounts",
"description": "Mock of the customer accounts service",
"version": "1.0.0",
"projectId": "66f1bf10e4b0a1b2c3d4e5a1",
"methodDefList": [
{
"id": "3f7c2a4e-7d0b-4a51-9a8e-0c1d2e3f4a5b",
"name": "/customers/{id}",
"description": "Returns one customer",
"httpMethod": "GET",
"summary": "Get customer",
"operationId": "getCustomer",
"tag": "Customers",
"parameterList": [
{
"name": "id",
"location": "path",
"type": "integer",
"required": true,
"example": "1",
"description": null
}
],
"requestBody": null,
"responseList": [
{
"uuid": "8b0e5f3a-2c4d-4e6f-8a1b-3c5d7e9f1a2b",
"httpStatusCode": "OK",
"headerList": [],
"description": "Customer found",
"exampleList": [
{
"uuid": "1d2e3f4a-5b6c-4d7e-8f9a-0b1c2d3e4f5a",
"name": null,
"responseContentType": "application/json",
"responseBody": "{\"id\": 1, \"name\": \"Customer 1\"}"
}
]
}
]
}
]
}
],
"resultCount": 1
}

Response Fields​

FieldTypeDescription
id, name, description, version, projectIdstringSame as in List Mock APIs
methodDefListarrayEndpoints of the Mock API
methodDefList[].namestringPath of the endpoint, for example /customers/{id}
methodDefList[].httpMethodstringHTTP method, for example GET
methodDefList[].descriptionstringEndpoint description
methodDefList[].summarystringOperation summary in the OpenAPI specification. When it is null, the specification uses the description.
methodDefList[].operationIdstringOperation ID in the OpenAPI specification. When it is null, the specification uses a generated value, for example get_customers.
methodDefList[].tagstringOperation tag in the OpenAPI specification. When it is null, the specification uses the Mock API name.
methodDefList[].parameterListarrayParameters of the endpoint. Each parameter has name, location (path, query, header, or cookie), type (string, integer, number, boolean, or array), required, example, and description.
methodDefList[].requestBodyobjectRequest body with mediaType, required, and schema (a JSON Schema as text). null when the endpoint has no request body.
methodDefList[].responseListarrayResponses of the endpoint. Each response has httpStatusCode (for example OK or NOT_FOUND), description, headerList (items with name and value), and exampleList.
methodDefList[].responseList[].exampleListarrayExamples of the response. Each example has name, responseContentType, responseBody, and policyCondition (the conditions of the example). An example without condition rules is the default example.

Error Response (400 Bad Request)​

The project has no Mock API with this name, or the user does not have the required permission.

{
"status": "FAILURE",
"resultMessage": "MockAPI (name: Customer Accounts) was not found!"
}

Error Response (401 Unauthorized)​

The token is missing or not valid. For the error format, see Error Handling.

cURL Example​

curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/mockapis/Customer%20Accounts/" \
-H "Authorization: Bearer YOUR_TOKEN"

Notes and Warnings​

  • Read-only: This endpoint does not modify anything and does not trigger a deployment
  • Name lookup: The name must match the Mock API name exactly. Encode spaces and special characters in the URL.
  • Reuse: You can send the returned object to Create or Update Mock API in another project or another Apinizer installation

Permissions​

  • User must have API_CREATOR + VIEW permission in the project