Calling Tyk internal API's

Hi Guys,

I’m wondering whether there is documentation on how to call the Tyk internal API’s to read-in Swagger definitions and configure Tyk e.g. through commandline CURL calls.

Also maybe there is a swagger file Tyk is exposing?

Hi Eric,

By this, do you mean that you would like documentation on how to manage Swagger definitions that you’ve imported into Tyk from the command line? If so, we unfortunately don’t have any documentation on how to do this as of yet (we are working on these).

When Swagger definitions are imported, they’re imported as API definitions so you should be able to read or list these using a GET request to the “/api/apis” path. If you would like to import new Swagger definitions from the terminal, you can do that with the following command:

  curl -X POST -H "authorization: xxxxxxxxx" -d @payload.json http://dashboard.tyk.local:3000/api/import/swagger 

where the payload.json file contains the following code with the Swagger definition nested within it as a JSON string:

{
  "swagger": "{JSON.Stringify(YourSwaggerDoc)}",
  "insert_into_api": false,
  "version_name": "V1",
  "upstream_url": "http://example.com"
}

Let me know if that answers your question or if your unsure of anything.

Kind regards,
Jess

1 Like

Thanks for this, Jess; I’m going to give your short tutorial a try! :slight_smile: