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 8168749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:37:51+00:00 2026-06-06T20:37:51+00:00

I am trying to use an API wrapper downloaded from the net to get

  • 0

I am trying to use an API wrapper downloaded from the net to get results from the new azure Bing API. I’m trying to implement it as per the instructions but getting the runtime error:

Traceback (most recent call last):
  File "bingwrapper.py", line 4, in <module>
    bingsearch.request("affirmative action")
  File "/usr/local/lib/python2.7/dist-packages/bingsearch-0.1-py2.7.egg/bingsearch.py", line 8, in request
    return r.json['d']['results']
TypeError: 'NoneType' object has no attribute '__getitem__'

This is the wrapper code:

import requests

URL = 'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query=%(query)s&$top=50&$format=json'
API_KEY = 'SECRET_API_KEY'

def request(query, **params):
    r = requests.get(URL % {'query': query}, auth=('', API_KEY))
    return r.json['d']['results']

The instructions are:

>>> import bingsearch
>>> bingsearch.API_KEY='Your-Api-Key-Here'
>>> r = bingsearch.request("Python Software Foundation")
>>> r.status_code
200
>>> r[0]['Description']
u'Python Software Foundation Home Page. The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to ...'
>>> r[0]['Url']
u'http://www.python.org/psf/

This is my code that uses the wrapper (as per the instructions):

import bingsearch
bingsearch.API_KEY='abcdefghijklmnopqrstuv'
r = bingsearch.request("affirmative+action")
  • 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-06T20:37:53+00:00Added an answer on June 6, 2026 at 8:37 pm

    I tested this out myself, and it seems what you are missing is to properly url-encode your query. Without it, I was getting a 400 code.

    import urllib2
    import requests
    
    # note the single quotes surrounding the query 
    URL = "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/Web?Query='%(query)s'&$top=50&$format=json"
    
    query = 'affirmative+action'
    
    # query == 'affirmative%2Baction'
    r = requests.get(URL % {'query': urllib2.quote(query)}, auth=('', API_KEY))
    print r.json['d']['results']
    

    Your example doesn’t make much sense because your request wrapper returns a list of results, yet in your main usage example you are calling it and then checking a status_code attribute on the return value (which is the list). That attribute would be present on the response objects, but you don’t return it from your wrapper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here is my problem: I am trying to use the bing api wrapper
I'm trying to use a Soundcloud API wrapper for the iPhone following these instructions
i'm trying use facebook API to upload photo in my fan page. I downloaded
I'm trying to use external api and display its results (after json parsing) on
I am trying to use Crocodoc api with the following code to get the
I am trying to use xml.etree.ElementTree to parse responses from eBay finding API, findItemsByProduct.
I'm trying to use the new version of the Google Translate API (V2) via
I'm trying to use Criteria API in my new project: public List<Employee> findEmps(String name)
I'm trying to use Tumblr API I believe its JSON. I'm trying to get
I'm trying to use an api to get information about movies, i'm useing this

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.