RESTful API
Mockgee offers REST API capabilities that enable you to generate mocks through API calls seamlessly integrated with your current CI/CD toolset and other platforms. This empowers you to efficiently create mock scenarios by leveraging the API functionality, thereby enhancing the process of simulating various test cases and interactions within your development workflow.
Steps to use REST API
Generate API key for API authentication
To create an API key in Mockgee, follow these steps from the Mockgee UI page:
- Navigate to the Administrator folder:
- From the Mockgee UI page, locate and click on the "Administrator" folder in the navigation.
- Access the API Key section:
- Within the Administrator folder, find and click on the "API key" option.
- Generate a new API key:
- On the API key page, look for the "Generate New API Key" button and click on it.
- Provide a name:
- When prompted, give a descriptive name for the new API key.
- Save the API key:
- Once the API key is generated, copy it and securely save it for future use.
By following these steps, you can successfully create and save a new API key in Mockgee, providing a secure means of authentication for your API interactions.
Add API key in Request Header
OpenAPI specification
openapi: 3.0.3
info:
title: Mockgee v1.3 REST API
description: Mockgee API v1.3
contact:
email: support@mockgee.com
name: Tanveer Iqbal
version: 1.3.0
externalDocs:
description: www.mockgee.com
url: https://mockgee.com
servers:
- url: http://hostname:8080
tags:
- name: Mock
description: Mockgeee API
externalDocs:
description: Find out more
url: https://mockgee.com
paths:
/api/mock/v1:
post:
tags:
- Add mock API
summary: add new mock to mockgee server
description: With this API at your disposal, you can easily generate stubs for your applications or tools on the fly, allowing for greater flexibility and efficiency in your development workflow.
parameters:
- in: header
name: x-api-key
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/StubRequest'
responses:
"201":
description: Successful operation
"400":
description: Invalid request data
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
"401":
description: Invalid api key
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
"500":
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
components:
schemas:
MockRequest:
type: object
required:
- payload
properties:
payload:
type: string
ApiResponse:
type: object
properties:
error:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
xml:
name: '##default'
StubRequest:
type: object
required:
- name
- stubs
properties:
name:
type: string
example: Strapi API
stubs:
type: array
items:
type: object
required:
- method
- path
- dataFormat
- response
properties:
description:
type: string
example: Creates a new restaurant
method:
type: string
example: post
path:
type: string
example: /api/restaurants
dataFormat:
type: string
example: json
request:
type: object
properties:
query:
type: array
items:
type: object
properties:
area:
type: string
example: LA
headers:
type: array
items:
type: object
properties:
key:
type: string
example: type
value:
type: string
example: restaurant
body:
type: string
example: 'JSON request body'
response:
type: object
required:
- code
properties:
code:
type: integer
format: int32
example: 200
headers:
type: array
items:
type: object
properties:
key:
type: string
example: org
value:
type: string
example: stc
body:
type: string
example: 'JSON response body'
config:
type: object
properties:
map:
type: array
items:
type: object
properties:
from:
type: string
example: id
to:
type: string
example: ID
filter:
type: object
properties:
type:
type: string
example: pick
paths:
type: array
items:
type: string
example: id