cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

redirects from api.meraki.com sockets

SOLVED
Getting noticed

redirects from api.meraki.com sockets

Hi team. 

Bit of an odd question. Using sockets to send my GET's, and if I send it directly to https://api.meraki.com it redirects to n151.meraki.com.

 

All well and good, I just followed the redirect and used that GET as my reference.

 

My question is if the API's all go through n151, or if I will really need to parse that initial response to the reply from https://api.meraki.com for the correct node. This is intended for anyone to be able to use, not just myself. 

1 ACCEPTED SOLUTION

Accepted Solutions
Kind of a big deal

Re: redirects from api.meraki.com sockets

Each org has a shard it's on, right? api.meraki.com attempts to identify the shard for your organization, then redirects to the correct shard. In this case, n151.

 

If you want to know the shard for a specific organization, you can use Get Organizations and then trim the org['url'] kinda like this. I'm using Python. Try running this in a Python shell.

 

Then you can just pass that to your request statement instead of api.meraki.com. Can speed things up a little...

 

 

org = {"id": "random", "name": "Test", "url": "https://n263.meraki.com/gibberish"}

print(f"Original URL: {org['url']}")
urlLength = org['url'].find('com') + 3
orgShard = org['url'][8:urlLength]

print(f"Trimmed shard URL: {orgShard}")

 

View solution in original post

9 REPLIES 9
Kind of a big deal

Re: redirects from api.meraki.com sockets

Each org has a shard it's on, right? api.meraki.com attempts to identify the shard for your organization, then redirects to the correct shard. In this case, n151.

 

If you want to know the shard for a specific organization, you can use Get Organizations and then trim the org['url'] kinda like this. I'm using Python. Try running this in a Python shell.

 

Then you can just pass that to your request statement instead of api.meraki.com. Can speed things up a little...

 

 

org = {"id": "random", "name": "Test", "url": "https://n263.meraki.com/gibberish"}

print(f"Original URL: {org['url']}")
urlLength = org['url'].find('com') + 3
orgShard = org['url'][8:urlLength]

print(f"Trimmed shard URL: {orgShard}")

 

View solution in original post

Getting noticed

Re: redirects from api.meraki.com sockets

Nash,

So if I send this 

 

GET /api/v0/networks/NETWORKNUM/clients HTTP/1.1
Host: api.meraki.com
Accept: application/json
x-cisco-meraki-api-key: keyhere
Content-Length: 15

timespan=1800

 

 

to  https://api.meraki.com, I get back

 

 

<html><body>You are being <a href="https://n151.meraki.com/api/v0/networks/NETWORKNUM/clients">redirected</a>.</body></html>

 

 

Just wanted to confirm that it changes based on the customers shard, which is sounds like is the case, and wasn't just n151 for all API stuff. Thanks for the clarification!

 

~Andrew Afonso~

Kind of a big deal

Re: redirects from api.meraki.com sockets

Strongly recommend you scrub that network number that you've included. That's why my example just said gibberish. 🙂

Getting noticed

Re: redirects from api.meraki.com sockets

Oof. Thought about that, but I thought the only confidential part was the API key. How dangerous is publishing the network num (Just want to know if I need to go searching if I've done it anywhere else). 

Kind of a big deal

Re: redirects from api.meraki.com sockets

To me it's all keys. Keys should be private, even if you need multiple keys in order to complete a transaction.

Kind of a big deal

Re: redirects from api.meraki.com sockets

This is a great example of why I have been promoting the use of dotenv, and for the complete removal of API keys and sensitive information from code.

 

https://community.meraki.com/t5/Developers-APIs/A-newer-safer-way-to-access-the-dashboard-API/m-p/69... 

Kind of a big deal

Re: redirects from api.meraki.com sockets

There is a new beta API service called "Mega Proxy" that does not use redirects.  You can try it out using api-mp.meraki.com instead of api.meraki.com.

Getting noticed

Re: redirects from api.meraki.com sockets

Lololol. Literally just finished & published the project I was asking for. But I may add that in. Can anyone just use the api-mp?

Kind of a big deal

Re: redirects from api.meraki.com sockets

>Can anyone just use the api-mp?

 

Yes.

Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.