originally posted in:BungieNetPlatform
View Entire Topic
Hi,
I posted this yesterday:
https://www.bungie.net/en/Forum/Post/184462705/0/0
but I think I posted in the wrong place so here is the question again.....
======================================================================
Previously I was able to "play" with the Bungie.net API in a normal browser just by typing URLs constructed from the documentation at:
https://www.bungie.net/platform/destiny/help/
but a few things have changed:
1) I've learned Python
2) I've learned JSON and how to parse it in Python
3) The bungie.net API access has changed to require the X-API-Key in the GET anyway
So I'm just playing about with:
$ unset http_proxy
$ python3
Python 3.2.3 (default, Jun 18 2015, 21:46:58)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>> import json
>>> foo = urllib.request.Request('http://www.bungie.net/Platform/Destiny/0/Account/wrightflyer_1903/Summary/', headers={ 'X-API-Key' : 'that_would_be_telling!!!'})
>>> str = urllib.request.urlopen(foo).readall().decode('utf-8')
>>> str
'{"ErrorCode":7,"ThrottleSeconds":0,"ErrorStatus":"ParameterParseFailure","Message":"Unable to parse your parameters. Please correct them, and try again.","MessageData":{}}'
>>>
So the thing "almost" works. I can clearly access the server and my use of 'foo' to build the request with modified headers={} and make the request has made the errors I was getting about X-API-Key go away but the ultimate response I'm getting is effectively an Error 7 meaning that "parameters" could not be parsed.
But what "parameters" is it talking about? Should the URL have "?something=some_value&something_else=some_other_value&etc." tagged onto the end. Otherwise what is it that I'm doing wrong here?
=================================================================
PS since my original post I have found an add-on for Firefox called "Modify Headers" which lets me make "normal" GET reuqests in a browser with the "X-API_key: xxxxx" added so I can still access the API with nothing more than Firefox but I would dearly like to know how that (which works) differs from the attempt in Python above (which doesn't)
English
-
There are two problems with this URL: http://www.bungie.net/Platform/Destiny/[b]0[/b]/Account/[b]wrightflyer_1903[/b]/Summary/ The first problem is that 0 is not a valid membershipType, you'll want to use either 1 for XBL or 2 for PSN. The second problem is the account parameter, the intended parameter is a membershipId (i.e. a number) rather than the display name. You can quickly find the parameters you want by going to the Gear page for an account/character you want to look up, for example this is one of my characters: https://www.bungie.net/en/Legend/Gear/2/4611686018428388123/2305843009215655427 The 2 is PSN and 4611686018428388123 is my Destiny membershipId. You would use these values to craft similar platform requests.