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

  • SEARCH
  • Home
  • 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 8381653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:44:31+00:00 2026-06-09T16:44:31+00:00

Basically, I’m trying to use the api offered by govtrack.us to pull information and

  • 0

Basically, I’m trying to use the api offered by govtrack.us to pull information and store into my own app’s datastore for further manipulation (using python). The api serves json by default and when i get the json I start to get lost on how to add each element I want to the datastore. For example, this json has the following keys: {u’meta’, u’objects’}. Each object has the following keys:

[u'gender_label', u'osid', u'id', u'pvsid', u'current_role', u'name_sortable', u'firstname', u'twitterid', u'middlename', u'lastname', u'bioguideid', u'birthday', u'link', u'youtubeid', u'nickname', u'name', u'roles', u'gender', u'namemod', u'metavidid', u'name_no_details', u'resource_uri']

I want to be able to take each object and store it into the datastore (but not all the information just some – like u’current_role’, u’youtubeid’, u’name’, etc…).

Right now, I’ve got this function that pulls the json:

def get_congressman():
url = 'http://www.govtrack.us/api/v1/person?roles__current=true&limit=3000'
content  = None
try:
    content = urllib2.urlopen(url).read()
except URLError:
    return
if content:
    return content

And this to iterate over the returned json:

current_congressman = get_congressman()
j            = json.loads(current_congressman)
name         = [c['name_no_details'] for c in j['objects']]
youtube      = [c['youtubeid'] for c in j['objects']]
gender_list  = [c['gender_label'] for c in j['objects']]

Instead of adding all the people’s names, gender, youtube feeds, etc. to a seperate list, I would like to add each object to their own list containing the information needed to add to the datastore. Basically, a list like:

["Gary Ackerman", "Male", "RepAckerman"]

But one for each object. What would be the best way to go about this? Or do I have to have a list of all names, another list of all genders, and so forth and then match them up?

  • 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-09T16:44:32+00:00Added an answer on June 9, 2026 at 4:44 pm

    First you need to define a model. See the Ndb Overview, for details.

    Lets say your model is something like

    class Congressman(ndb.model):
        ...
    

    Then instead of computing one list of names, other for youtube ids, you will traverse all the objects once and create a Congressman object and store it.

    for congressman_info in j['objects']:
        congressman = Congressman(gender=congresmman_info['gender_label'],
                                  name=congressman_info['name_no_details'], ...)
        congressman.put()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I
Basically, I'm trying to split a massive 1D vector into blocks of a given
Basically I want to check the extended permissions the user has granted my app.
Basically, what I'm trying to create is a page of div tags, each has
Basically what I'm trying to do is make a very simple vertical bullet projectile
Basically, I'm implemeting a reversi app for android for my year 13 coursework and
Basically I have converted a tab delimited txt file into a list containing a
Basically this function is meant to store the height value of the element that
Basically, I'm developing a note-taking app where the user can type as long as
Basically I'm trying to improve on the Ghosts in a Pacman game I'm making.

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.