Manage Tyk API's using REST


#1

Dear Community,

I am playing with the (tyk-gateway) REST API and it works quite nice to some extend. Querying API’s and keys works perfectly fine. However creating new API definitions or keys don’t work even though the output i get from my curl commands give me a successful status message.

For instance,
Creating a new API (by using the output of a current API with a new name and identifying info):
Response: {“key”:“XXXXXXXXX46f06674a5b98eafcc21”,“status”:“ok”,“action”:“added”}
new app: /opt/tyk-gateway/apps/XXXXXXXXX46f06674a5b98eafcc21.json

next i do a REST reload / restart of entire tyk-gateway daemon and still i don’t see the new API in my dashboard, nor do i see it in my REST query for current API’s.

I conducted the queries using info from the swagger.yaml API specification and the documentation i could find from the website.

So am I doing something wrong or forgetting an essential step?

Thank you in advance!

edit: I’m aware of the importance of a correct organisation ID, this is aligned with the current (default organisational ID)


#2

Are you using the dashboard? If so, this request (to the gateway API) will just add file based API’s and will be ignored by the gateway because it is using the dashboard as master.

If you are using the dashboard, then use the dashboard API endpoints.


#3

I am indeed using the dashboard. So let’s say I am going to use the dashboard endpoints, do i need to use the same API calls on the dashboard port (which defaults to 3000) in combination with the credentials of a dashboard user? Or does this require a total different approach?

update1: If the approach is going to be different I’d be glad to hear where i can find instructions / documentation.

update2: I think I’m starting to get this, this is about the seperation between de gateway API and the advanced management API, https://tyk.io/docs/tyk-advanced-management-api-v-0-9/api-definitions/

update3: Interesting, following the example of the advanced-management-api instructions i get this response creating a new API: {“Status”:“OK”,“Message”:“Org created”,“Meta”:“57390…800000a”}

Still no new API shows up in my list…


#4

Are you running an old version?

The API docs are here:

https://tyk.io/docs/tyk-dashboard-v1-0/dashboard-api/

If APIs load using the dashboard then all is working and the problem is with your request.

The Tyk gateway log file will tell you why the API isn’t loading at the gateway level (might be a dupe listen path). To confirm if the data is written you need to check using the dashboard, if it’s listed, it wrote ok and the problem will be elswhere.


#5

Hi Martin,

Thank you for the rapid response! I ended up on that page via a google search page, no idea why it led me to the old docs page. Anyway I’m using the exact example as presented in the recent documentation but still I don’t get new API definition via REST. Can you advise me about verbosity flags or options I can enable to gather more details?

Thanks again :slight_smile:


#6

Sorry I just saw this response in your first post - you would only get that response if you were creating an Organisation, are you sure you called the right endpoint?

Or are you creating an org and then an API? If that’s the case then you’re going multi-tenant, and the API will be part of another organisation :slight_smile:

The real question is: Can you create APIs with the dashboard?

If you can, then your setup is fine, but your use of the API is wrong.


#7

Aah, ok. Things get more clear now. We have different end-points for organizations, and even different pairs of credentials. I missed this part of the architecture… Creating API definitions via the dashboard work perfectly fine. I think i’ll get rid of the whole dashboard thing and switch to a file-based tyk-gateway only setup (for my current project at least). There is a lot less complexity that way.

We are about to order a ‘professional edition’ version of Tyk and make a more company-wide setup for our APIs. Then the multi-organization aspect is really an added value.

I appreciate your feedback :slight_smile:

p.s: So yes, I’m working with one organization right now.