asyncbing API reference#

Searching#

asyncbing.search(auth: str, *, session: Optional[aiohttp.client.ClientSession] = None)#

Takes a auth token, as well as an optional aiohttp session.

It is recommended to use this function instead of asyncbing.Translate as it returns it, and you can use async with syntax in it.

example:

async with asyncbing.search('AUTHTOKEN') as searching:
  await searching.fetch...

class asyncbing.Search(auth: str, *, session: Optional[aiohttp.client.ClientSession] = None)#

The searching part of asyncbing.

If you manually initialize this class, you won’t be able to use the async with syntax. It’s recommended to use asyncbing.search().

async fetch(search: str) asyncbing.searchresponse.SearchResponse#

This function is a coroutine.

Searches with the bing api for the search string provided, with the global market set.

async search(search: str) asyncbing.searchresponse.SearchResponse#

This function is a coroutine.

An alias for asyncbing.Search.fetch()


class asyncbing.SearchResponse(data)#

Represents a Bing Response (not a search result response)

Warning

You must not manually initialize this!

getMany(amount: int, *, start: int = 0) Tuple[asyncbing.searchresult.SearchResult]#

Returns as many asyncbing.SearchResult as you want as the max defined by the int passed into the function. has an optional start kwarg. Defaults to 0.

getNext() asyncbing.searchresult.SearchResult#

Gets the next result and returns a asyncbing.SearchResult

getOne() asyncbing.searchresult.SearchResult#

Gets the top search result and returns a asyncbing.SearchResult.

getThree() Tuple[asyncbing.searchresult.SearchResult, asyncbing.searchresult.SearchResult, asyncbing.searchresult.SearchResult]#

Gets the top three search results and returns a tuple of asyncbing.SearchResult

property matches: int#

Returns the amount of estimated matches found for your search query

property originalQuery: str#

Returns a string if for some reason you forgot what you searched for

property searchUrl: str#

Returns the bing search url you would get if you were to type in the query in the bing website directly.


A searchresult represents a search result response from bing (you get it from asyncbing.SearchResponse).

class asyncbing.SearchResult(data)#

Represents a Bing Search Result (like url, snippet, name, etc)

Warning

You must not manually initialize this!

property dateLastCrawled: datetime.datetime#

Returns when the page was last crawled by Bing as a datetime.datetime object.

property displayUrl: str#

The display url of the Search Response. I don’t actually know what this is, I think it is a trimmed version of the url

property isFamilyFriendly: bool#

Returns a bool if the Search Response is family friendly.

property isNavigational: bool#

I have no idea what this is. Returns a bool if page is navigational.

property language: str#

Returns what language the page is in.

property name: str#

Returns the name of the Search Response.

property snippet: str#

Returns a snippet of the content on the webpage. It’s the description/snippet below the url and name.

property url: str#

Return the url of the Search Response.


Translating#

asyncbing.translate(auth: str, *, region: Optional[str] = None, session: Optional[aiohttp.client.ClientSession] = None) asyncbing.translate.Translate#

Takes a auth token, as well as an optional aiohttp session.

It is recommended to use this instead of manually initializing asyncbing.Translate because you can use the async with syntax, and it returns asyncbing.Translate.

example:

async with asyncbing.translate('AUTHTOKEN', region='eastus') as translating:
    await translating.translate...

class asyncbing.Translate(auth: str, *, region: Optional[str] = None, session: Optional[aiohttp.client.ClientSession] = None)#

The translating part of asyncbing. If you use this class, you won’t be able to use the async with syntax. It’s recommended to use asyncbing.translate()

async translate(query: str, *, tolang: str = 'en', fromlang: Optional[str] = None) asyncbing.translateresponse.TranslateResponse#

This function is a coroutine.

Translate the given query with an optional tolang language to translate to, as well as an optional fromlang language to translate from. If tolang isn’t provided, it will auto translate to english. If fromlang isn’t provided, it will auto translate from autodetect.


class asyncbing.TranslateResponse(data: dict)#

The class for the Bing Translate Response.

Warning

You must not manually initialize this!

property detected_language: str#

Returns the translated output of the query.

property translated_language: str#

Returns the language of the translated output.

property translated_output: str#

Returns the translated output.


Exceptions#

class asyncbing.BingException#

A generic exception for all bing-related exceptions. You can catch all exceptions with this.

class asyncbing.BadAuth#

An invalid authorization was passed in

class asyncbing.NotEnoughResults#

There weren’t enough results.