Creating an API definition using the analytics dashboard = lost

Imported Google Group message. Original thread at: Redirecting to Google Groups Import Date: 2016-01-19 21:02:37 +0000.
Sender:Marc Calder.
Date:Friday, 24 October 2014 18:19:43 UTC+1.

So I’m trying (desperately) to get a Tyk installation up and running. I’ve met with partial success, and am now at an impasse.

I’ve installed tyk and have proved proper operation using the quickstart json config. I’ve installed the tyk-analytics package and have gotten it up and running. I’ve created an org and a user, and am able to log into the web site okay. So far so good.

I created an api definition, and read this helpful text on the right of the screen: "Help
Creating a new API will create a new subdomain that will begin accepting requests and proxying them to your defined endpoint immediately.
The problem I have is that there is no indication anywhere what this new subdomain is called or how the proxy responds to it.
I’ve pulled the api definition out of the tyk_apis mongo collection and here it is for illustration:
{ “api_model” : { }, “_id” : ObjectId(“544a867bac40f217a1000002”), “name” : “httpbinopen”, “api_id” : “d084cb7f9d914802709a7f9b694694ae”, “org_id” : “544a85ebac40f217a1000001”, “use_oauth2” : false, “use_keyless” : true, “enable_signature_checking” : false, “oauth_meta” : { “allowed_access_types” : [ ], “allowed_authorize_types” : [ “token” ], “auth_login_redirect” : “” }, “notifications” : { “shared_secret” : “”, “oauth_on_keychange_url” : “” }, “definition” : { “location” : “header”, “key” : “” }, “version_data” : { “not_versioned” : true, “versions” : { “Default” : { “name” : “Default”, “expires” : “2014-10-24 00:00”, “paths” : { “ignored” : [ ], “white_list” : [ ], “black_list” : [ ] } } } }, “proxy” : { “listen_path” : “/d084cb7f9d914802709a7f9b694694ae/”, “target_url” : “http://httpbin.org”, “strip_listen_path” : true }, “auth” : { “auth_header_name” : “” }, “active” : true }
As you can see, the name of the api is httpbinopen (for “An api to proxy httpbin.org” with open - keyless - access).

Can you please tell me where to go from here? It would be really great if you could give me an example bit of curl that would illustrate how to access a newly created api.

Thanks!

Imported Google Group message.
Sender:Martin Buhr.
Date:Friday, 24 October 2014 18:38:39 UTC+1.

Hi Marc,
You’re right, the documentation in the dashboard is a little thin on that point, it was originally designed to be part of a hosted service and used with the host-manager to run the NginX configuration in line with the API definition.
We should have that updated with the next dashboard release.
Your api will be available at:
http://{hostname}:{port}/{api-id}/
So if you are using the self contained example, it should be something like this:
http://localhost:8080/d084cb7f9d914802709a7f9b694694ae/
I hope that helps, we’re working on getting the documentation up for the dashboard as well as an overall update to Tyk (which has been the main focus for now).
Let me know if this works,
Cheers,
Martin

Imported Google Group message.
Sender:Marc Calder.
Date:Friday, 24 October 2014 18:38:39 UTC+1.

Hi Marc,
You’re right, the documentation in the dashboard is a little thin on that point, it was originally designed to be part of a hosted service and used with the host-manager to run the NginX configuration in line with the API definition.
We should have that updated with the next dashboard release.
Your api will be available at:
http://{hostname}:{port}/{api-id}/
So if you are using the self contained example, it should be something like this:
http://localhost:8080/d084cb7f9d914802709a7f9b694694ae/
I hope that helps, we’re working on getting the documentation up for the dashboard as well as an overall update to Tyk (which has been the main focus for now).
Let me know if this works,
Cheers,
Martin

Imported Google Group message.
Sender:Martin Buhr.
Date:Friday, 24 October 2014 18:46:10 UTC+1.

Thanks for the quick reply Martin. I see what you’re getting at with the api id after the host/port. I tried the snippet you put together, but got a 404 error.

ubuntu@ip-10-245-1-85:~$ curl http://localhost:8080/d084cb7f9d914802709a7f9b694694ae/ip
404 page not found

Maybe I messed up the definition of the api? A very similar definition is what I successfully used in the quickstart.json definition. Can you please take another look at the mongo api definition object that I posted previously and let me know if I messed up somewhere?

Imported Google Group message.
Sender:Marc Calder.
Date:Friday, 24 October 2014 19:09:25 UTC+1.

Hi Marc,

A few things to check, if that URL isn’t working, it could be that Tyk hasn’t picked it up, have you restarted the main Tyk process?

Alternatively, you could send your Tyk process a soft reload using the Tyk API: http://tyk.io/rest-api/hot-reload/

But for the sake of getting things working, it may be easier to just kill the tyk process with ctrl+c and then run ./tyk again.

If Tyk is configured to pull configs from Mongo, it should reload them and you will see it in the console output as a loaded API.

If you post your console output after restarting the main Tyk process it should shed some light as to what may be going wrong.

(If I stop responding it may be because I’m not in the office, apologies - currently typing under the watchful gaze of my partner, in a restaurant - she is long suffering ;-). )

Cheers,
Martin

Imported Google Group message.
Sender:Marc Calder.
Date:Friday, 24 October 2014 19:24:17 UTC+1.

That did the trick. Thanks Martin, and apologies to your partner…

Imported Google Group message.
Sender:Martin Buhr.
Date:Friday, 24 October 2014 20:28:08 UTC+1.

Excellent - let me know if you have any other questions, you can always email me direct :slight_smile:
Have a good weekend!
Thanks,
Martin