API Caller RESTful API Documentation

 

 

API Caller via Postman

https://docs.google.com/document/d/1vkDek8aHX1vfu0oDOzNltW47YQl7LXmi1Rb-Vh61rOc/edit?usp=sharing

How to get the authorization token and use it

 For this documentation, we will use http://mock-api-caller.openlegacy.com/ DNS.

  1. Go to Postman and enter the following header :

            POST: http://mock-api-caller.openlegacy.com/iam/auth/token

  1.  Go to Body → select row → select JSON from the drop-down list.

  2. Enter in the username and the password in a JSON format. 

            For example: 

            {"username": "admin@openlegacy.com", "password": "password"}

3. If the login details are correct you’ll receive a token in the response body. 

How to get JWKS

JWKS is a public key, we can receive it with a simple GET method.

  1. Go to Postmen and enter the following header:
    GET: http:/mock-api-caller.openlegacy.com//iam/.well-known/jwks.json

  2. Send.

  3. Now the JWKS are in the response body.

    { "keys": [ { "alg": "RS256", "kty": "RSA", "use": "sig", "n": "****", "e": "****", "kid": "****", "x5c": [ "****" ], "x5t": "****" } ] }

How to login with the token

For each endpoint, we need to add a token to the header for authorization. 

  1. Go to Authorization → choose Bearer Token from the Type drop-down list.

  2. Enter the token into the Token text box. 

  3. Go to Headers

  • key: Authorization 

  • value: Bearer <The Token you Received> 

    Now you ready to work with the API caller via Postman. 

Note! after several times the token session will end and you’ll need to get a new one.  


Users management  endpoints 

Add user -endpoint 

  1. Insert the following URL: 

            POST: http://mock-api-caller.openlegacy.com/iam/api/v1/user/create

  1. Go to Body → select row → select JSON from the checklist.

  2. Edit the following JSON with the details of the user.

   { "username": "username@email.com", "password": "password", "is_admin": false     }

3. Insert the JSON into the body request. 

4. Send.

You successfully created a new user.

Delete user - endpoint 

Delete a user by username. 

  1. Insert the following URL: 

           DELETE: http://mock-api-caller.openlegacy.com/iam/api/v1/user/delete 

2. Go to Body → select row → select JSON from the checklist.

3. Edit the following JSON with the name of the user you want to delete.

{"username": “username”}

4. Insert the JSON into the body request. 

5. Send.

You successfully deleted a user.  

Using the API Caller endpoints 

 Get all endpoints-endpoint

This endpoint lets us see all the endpoints we have in the API Caller. 

  1. Insert the following URL:  

            GET: http://mock-api-caller.openlegacy.com/api/v1/endpoints

2. Send. 

Now you can see all the endpoints. 

 

Convert-endpoint

In a case of using Swagger, 2.0 use the convert-API endpoint to convert it from swagger 2.0 to OpenAPI 3.0. 

  1. Insert the following URL:

           POST: http://mock-api-caller.openlegacy.com/api/v1/specification/openapi/convert 

2. Go to Body → select row → select JSON from the checklist.

3. Paste the JSON you want to convert to the body request. 

4. Send. 

Now you have an OpenAPI 3.0 JSON.



Parse-endpoint  

Service that gets swagger specification file content as input, parses it, converts the parse results to endpoints, and returns the endpoints to the user.

  1. Insert the following URL:

              POST: http://mock-api-caller.openlegacy.com/api/v1/specification/openapi/parse

2. Make sure that you have a swagger specification in OpenAPI 3.0 format(use /api/v1/specification/openapi/convert endpoint if needed) and stringify it. 

3. Go to Body → select row → select Text from the checklist.

4. Copy the stringify swagger specification into the body request

5. Send.

Behind the scenes: the endpoint - POST: /api/v1/blunk/create invoked and created the endpoints and stored them in the DB. You successfully created new endpoints.  

Delete- endpoint 

Receives an endpoint’s ID or a set of endpoint IDs and deletes the corresponding endpoints.

  1. Insert the following URL:

           DELETE: http://mock-api-caller.openlegacy.com/api/v1/endpoints/bulk/delete

2. Go to Body → select row → select JSON from the checklist.

3. Edit the following JSON with the endpoints’ IDs that you want to delete. 

       

    {                "endpointsIds": [                   "endpoint-id"                  ]               }

4. Insert the JSON into the body request. 

5. Send.

You successfully deleted endpoints. 



Import - Endpoint

When importing a Swagger specification to API Caller, each endpoint in the specification will also hold a reference to a the specification it was derived from.

  • The Specification name will be derived from the Swagger Info-->title property

  • Each spec will have a unique identifier (UUID) - specId

    • If no info.title is specified in the Swagger file:

      • A default name will be generated: Specification_xxxxxxx

      • With the last 7 digits of the Specification ID (uuid)
        example: Specification_1ab23tt

  • Each endpoint will hold a reference to its specification

  • If an endpoint already exists with the same specId (UUID), the existing endpoint will be updated (including the specification name) and its Status will be maintained

  1. Insert the following URL:

              POST: http://mock-api-caller.openlegacy.com/api/v1/endpoints/import

2. Go to Body → select row → select JSON from the checklist.

3. Enter a Swagger specification JSON of the endpoints you want to import into the body.

Note! make sure you’re removing the ID field. 

4. Send.

You successfully imported an endpoint.

 

Export - endpoint 

All endpoints that were derived from the same swagger specification can be exported in a single call by specifying the Spec ID in the API call. the resulting JSON file will contain all relevant endpoints and their related specification.

When exporting multiple endpoints to a single JSON file, the base-url in the exported endpoints can be changed. This eases the exporting of multiple endpoints in one environment and then importing them into another.

The API receives a set of endpoints IDs and returns the corresponding endpoints when using the export option on one or more endpoints, inside its logic it invokes the POST:  /get bulk endpoints. 

  1. Insert the following URL:

              POST: http://mock-api-caller.openlegacy.com/api/v1/endpoints/export

2. Go to Body → select row → select JSON from the checklist.

3. Edit the following JSON with the endpoints’ IDs that you want to export. 

       

4. Insert the JSON into the body.

5. Send. 

Now you received a JSON with endpoints’ specifications. 

When exporting endpoints using the API:

  • Add base-url string to API call to replace the exported endpoints base-url property :

    • When added (even with empty string value) , it replaces the original base-url for each of the specified endpoints to the new base-url specified in the API

      • Validation: Only characters that are allowed in URLs are allowed

    • When not added to the API call , doesn’t change the original base-url in any of the specified endpoints.

    • When the base-url is specified with an HTTP schema prefix (such as: http:// … ):

      • Change the HTTP schema property to match the new URL’s

      • Change the base URL as required.

 

Publish - endpoint

Receives one endpoint’s ID or a set of endpoint IDs and updates the status of the corresponding endpoints to PUBLISH.

  1. Insert the following URL:

PUT: http://mock-api-caller.openlegacy.com/api/v1/endpoints/bulk/publish

  1. Go to Body → select row → select JSON from the checklist.

  2. Edit the following JSON with the endpoints’ IDs that you want to publish. 

        

3. Insert the JSON into the body.

4. Send. 

Now the status of those endpoints changed from DRAFT to PUBLISH. 

 

Unpublish - endpoint

Receives one endpoint’s ID or a set of endpoint IDs and updates the status of the corresponding endpoints to DRAFT.

  1. Insert the following URL:

PUT: http://mock-api-caller.openlegacy.com/api/v1/endpoints/bulk/unpublish

2. Go to Body → select row → select JSON from the checklist.

3. Edit the following JSON with the endpoints’ IDs that you want to unpublish. 

          

4. Insert the JSON into the body.

5. Send. 

Now the status of those endpoints changed from PUBLISH to DRAFT. 

Edit - endpoint

Receives an endpoint definition and updates the corresponding endpoint with the given endpoint definition.

  1. Insert the following URL:
    PUT: http://mock-api-caller.openlegacy.com/api/v1/endpoints/:id

  2. Use the /get endpoint to get the swagger specification of the endpoint that you want to update.

  3. Go to Params and define the ID as a path variable. 

  4. Go to headers and define Accept as application/json.

  5. Copy the endpoint’s definition scope into the request body. 

For example:

6. Edit the fields you want. 

7. Send. 

You successfully updated an endpoint.