Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9195307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:36:02+00:00 2026-06-17T21:36:02+00:00

I am trying to fetch JSON data using the discogs API, but the code

  • 0

I am trying to fetch JSON data using the discogs API, but the code doesnt seem to give the output I see when I paste the data in a browser as raw. Kindly let me know what I am doing wrong here as I am new to Python. I was looking to get the output for title, images. Thanks!

Python:

import urllib
import urllib2
import json
url = 'http://api.discogs.com/masters/66271'
request = urllib2.Request('http://api.discogs.com/masters/66271')
request.add_header('User-Agent','Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')
request.add_header('Content-Type','application/json')
response = urllib2.urlopen(request)
json_raw= response.readlines()
json_object = json.loads(json_raw[0])
print json_object
for row in json_object:
    print row
            print row['title']

wrong output:

styles
genres
videos
title
main_release
main_release_url
uri
artists
versions_url
year
images
resource_url
tracklist
id
data_quality
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:36:03+00:00Added an answer on June 17, 2026 at 9:36 pm

    You should not use .readlines(). Let the json library do the reading:

    response = urllib2.urlopen(request)
    json_object = json.load(response)
    

    Note the function name, .load(), no s at the end.

    The object returned is a dictionary; each of the strings you see is a key into that dictionary. You need to specify what titles you’d want; the tracklist and videos entries both have a list of items with titles; here is how you’d print the tracklist entry titles:

    for track in json_object['tracklist']:
        print track['title']
    

    Which prints:

    HIStory Begins
    Billie Jean
    The Way You Make Me Feel
    Black Or White
    Rock With You
    She's Out Of My Life
    Bad
    I Just Can't Stop Loving You
    Man In The Mirror
    Thriller
    Beat It
    The Girl Is Mine
    Remember The Time
    Don't Stop 'Til You Get Enough
    Wanna Be Startin' Somethin'
    Heal The World
    HIStory Continues
    Scream
    They Don't Care About Us
    Stranger In Moscow
    This Time Around
    Earth Song
    D.S.
    Money
    Come Together
    You Are Not Alone
    Childhood (Theme From "Free Willy 2")
    Tabloid Junkie
    2 Bad
    History
    Little Susie
    Smile
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a chart using data from my database calling json, but
I'm trying to pull data into flash using JSON but i keep getting this
I'm trying to fetch some JSON data from my server like so: var a
I'm trying to fetch data from a div (based on his id), using PHP's
I am trying to fetch data from database using php and send it to
I am trying to parse a result (JSON) fetched from the Facebook API using
im retrieving the Array of JSON data and trying to diplay and access it.But
I'm trying to make it easy for me to request json output using jquery
I'm trying to parse an NSString that contains JSON data into an NSDictionary using
I am displaying data from database using PHP. I am using JSON. but during

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.