api¶
from instahashtag import api
Direct API call to DisplayPurposes with json returns. Support for synchronous and asynchronous
function call.
Note
This module can either be used synchronous or asynchronous via the aio flag passed to each
of the functions below. By default aio is set to False, but when setting it to True
the return will be an Awaitable that can be await to query the API.
- Example
One may use the
aioflag to dictate whether to use the function asynchronously or synchronously.from instahashtag import api def io(): """Uses 'requests' to send requests.""" tag = api.tag(hashtag="instagram") graph = api.tag(hashtag="instagram") maps = api.maps( x1=-80.48712034709753, y1=25.750749758162012, x2=-79.82794065959753, y2=25.854604964203453, zoom=12, ) async def aio(): """Uses 'aiohttp' to send requests.""" tag = await api.tag(hashtag="instagram", aio=True) graph = await api.tag(hashtag="instagram", aio=True) maps = await api.maps( x1=-80.48712034709753, y1=25.750749758162012, x2=-79.82794065959753, y2=25.854604964203453, zoom=12, )
-
tag(hashtag: str, aio: bool = False) → Union[dict, Awaitable][source]¶ Sends a request to the server.
- Parameters
hashtag – Hashtag to retrieve info from.
aio – If set to
Truewill return a Future for use withawaitkeyword. Defaults toFalse.
- Returns
Dictionary with given data (see Notes below).
Note
The return dictionary follows the following format:
{ geo: [float, float], rank: int, results: [ { absRelevance: float, geo: [float, float], media_count: int, rank: int, relevance: int, tag: str } ... ], tag: str, tagExists: bool }
-
graph(hashtag: str, aio: bool = False) → Union[dict, Awaitable][source]¶ Generates graphing query to send to the server.
- Parameters
hashtag – Hashtag to retrieve info from.
aio – If set to
Truewill return a Future for use withawaitkeyword. Defaults toFalse.
- Returns
Dictionary with given data (see Notes below).
Note
The return dictionary follows the following format:
{ edges: [ { a: str, b: str, id: str, weight: float } ... ], exists: bool, nodes: [ id: str, relevance: float, weight: float, x: float, y: float ], query: string, root_pos: [float, float] }
-
maps(x1: float, y1: float, x2: float, y2: float, zoom: float = 1, aio: bool = False) → Union[dict, Awaitable][source]¶ Generates graphing query to send to the server.
- Parameters
x1 – Top left x-coordinate corner of the map.
y1 – Top left y-coordinate corner of the map.
x2 – Bottom right x-coordinate corner of the map.
y2 – Bottom right y-coordinate corner of the map.
zoom – Number from 2 to 16 that designates the zoom factor.
aio – If set to
Truewill return a Future for use withawaitkeyword. Defaults toFalse.
- Returns
Dictionary with given data (see Notes below).
Note
The return dictionary follows the following format:
{ count: int tags: [ { "centroid": [ 0: float 1: float ], tag: str, weight: int } ... ] }