Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change default encoding of API calls to 'utf-8' #663

emileaben opened this issue Mar 11, 2020 · 2 comments

change default encoding of API calls to 'utf-8' #663

emileaben opened this issue Mar 11, 2020 · 2 comments


Copy link

@emileaben emileaben commented Mar 11, 2020

As I've struggled many hours now with the interaction between the
python2 (don't ask, but for this i couldn't switch to python3 ...)
requests library and peeringDB API, I'd like to make the following
suggestion for change.

If I query:

The response headers say:
content-type: application/json; charset=iso-8859-1

I think it makes more sense to have the charset be 'utf-8' for the json

The current charset (iso-8859-1) causes python programmers extra steps trying to convert this to unicode. For instance, in the much used python requests library you need
to know and understand this. The standard approach is this:

r_ixlan = requests.get("")
j_ixlan = r_ixlan.json()

to get the json output (but all kinds of hell happens when you try
manipulating for instance the ixp 'name' field that contains non-ascii

What one needs to do to get this right:

   r_ix = requests.get("")
   # do this differently because ascii/utf-8 etc.
   r_ix.encoding = 'utf-8'
   r_ix_txt = r_ix.text
   j_ix = json.loads( r_ix_txt )
   # ^^---- these 3 lines are hours of effort 

In my case I have the solution now, but I think it will save hours of
pain on people trying to program against peeringDB if you make this change.
Happy to make a twitter poll or somesuch to see if i'm the only one who
had to deal with this.

hope this helps make peeringDB even better!

thanks for providing this service, it's awesome

best regards,
Emile Aben

@arnoldnipper arnoldnipper self-assigned this Mar 11, 2020
@arnoldnipper arnoldnipper added this to the 1 Decide milestone Mar 11, 2020

This comment has been minimized.

Copy link

@arnoldnipper arnoldnipper commented Mar 11, 2020

@peeringdb/pc makes sense to me, hence +1. But would like to hear the programmer's pov ... @grizz and @vegu


This comment has been minimized.

Copy link

@shane-kerr shane-kerr commented Mar 11, 2020


I'm fully in favor of moving everything to UTF-8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.