How to call and get Tyk Apis?


I am using Tyk gateway version 4.2.3 and deploying it through docker compose ( GitHub - TykTechnologies/tyk-pro-docker-demo: Tyk Pro demo using docker and docker compose, supercedes tyk_quickstart.

I put a hostname for this gateway, like

I noticed that I can curl and get the API by using the hostname, like curl (I created an api call myapi).

When I tried to called curl localhost:8080/hello, it is working, and showing the proper message:

{“status”:“pass”,“version”:“4.2.3”,“description”:“Tyk GW”,“details”:{“dashboard”:{“status”:“pass”,“componentType”:“system”,“time”:“2023-02-14T04:11:40Z”},“redis”:{“status”:“pass”,“componentType”:“datastore”,“time”:“2023-02-14T04:11:40Z”}}}

However, when I tried to use curl localhost:8080/myapi, it showed not found message.

I am just wondering why I cannot access the Tyk api using curl localhost:8080/myapi?

Is there any reason for this? Is it because I set a hostname for Tyk on the config file? Or is this a bug on Tyk?


Maan Tarng

Because you have configured the gateway to specifically listen on the hostname. Anything else would be ignored. If you are looking for an alternative, then mapping a DNS record might be what you want.

This isn’t a bug. It’s by design. Imagine if the gateway is deployed internally withing a network but still made available externally via the the specified hostname. The liveness check endpoint and all other gateway APIs are still available internally for use. Which means external users are restricted from making admin calls to the gateway.

@Olu Thanks for your help and clarification.