Skip to main content

Social APIs is a library providing an easy way to access Social Networks APIs.

Project description

Social APIs

Social APIs is a Python library providing an easy way to access Social Networks API.

This library was designed to explore the possibility of a unified integrations with multiple social networks, without an intermediate layer.

This is an attempt to combine several social networks SDKs into one library and generalize their use.

Features

  • Build flexible requests to following social networks APIs: Facebook, LinkedId, Twitter v1/v2, VK
  • Use build-in methods with documentation links
  • Build your query flexibly with arguments mapping
  • Use the basic request method if you do not find the desired function
  • OAuth 1/2 support
  • Fully Python 3 support (python 2 not support at the moment)

Installation

Install Social APIs via pip:

$ pip install social-apis

Or, if you want the code that is currently on GitHub:

git clone https://github.com/azavodov/social-apis
cd social-apis
python setup.py install

Get started

First, you must register the application and get access keys for requests. This is a common step for any social network.

After you register, copy the credentials, we won't need them. This can be an access_token in case of Oauth 2 authorization,

or a combination of token and token secret in the case of Oauth 1 authorization.

Then, you'll want to import some social networks. Facebook for example:

from social_apis.networks.facebook import Facebook 

Next, initialize one of the api classes. To do this, transfer any credentials, supported by this social network.

The authorization method will be recognized automatically depending on the passed parameters.

access_token = "<< FACEBOOK_ACCESS_TOKEN >>"
facebook_api = Facebook(access_token=access_token) 

Cool! Now you can call methods and build requests!


Examples

Oauth 1.0 – Twitter authentication

import os
from social_apis.networks.twitter import Twitter

app_key = os.environ.get("TWITTER_APP_KEY")
app_secret = os.environ.get("TWITTER_APP_SECRET")
oauth_token = os.environ.get("TWITTER_TOKEN")
oauth_token_secret = os.environ.get("TWITTER_TOKEN_SECRET")

twitter_api = Twitter(
    app_key=app_key, 
    app_secret=app_secret, 
    oauth_token=oauth_token, 
    oauth_token_secret=oauth_token_secret
)

Use the build-in method without arguments

from social_apis.networks.vkontakte import Vkontakte

vk_api = Vkontakte(access_token="<< VK_ACCESS_TOKEN >>")
settings = vk_api.account_get_push_settings()

Use the build-in method with arguments mapping

from social_apis.networks.vkontakte import Vkontakte

vk_api = Vkontakte(access_token="<< VK_ACCESS_TOKEN >>")
users = vk_api.users_search(q="Ivan Ivanov", count=7)

Use the GET request method with custom endpoint and params

from social_apis.networks.facebook import Facebook

facebook_api = Facebook(access_token="<< FACEBOOK_ACCESS_TOKEN >>")
endpoint = facebook_api.url + "/posts/search"
response = facebook_api.get(endpoint, params={'q': 'github'}) 

Dynamic Function Arguments

Keyword arguments of functions are mapped to the functions available for each endpoint in any APIs docs. Doing this allows you to be really flexible in querying the API, so changes to the API aren't held up from you using them by this library.

Questions, Comments, etc?

If you have any questions, you can contact me through the following social networks:

Special Thanks

During the development process, following SDKs and projects were studied and helped me a lot with library features and structure!

twython, python-facebook-api, vk_api

Thank you a lot!

Want to help?

There are many plans for the development of this library.

However, if you would like to help or contribute, any pull requests, advices or discussions are most welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

social-apis-1.0.tar.gz (19.4 kB view details)

Uploaded Source

File details

Details for the file social-apis-1.0.tar.gz.

File metadata

  • Download URL: social-apis-1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.10

File hashes

Hashes for social-apis-1.0.tar.gz
Algorithm Hash digest
SHA256 90709921394ee19a930ca28bf373f2c924f0002d41d9735ce36c5f417d6bd6ef
MD5 2c996ad0ecab64263d229c1a1cf94a95
BLAKE2b-256 0fa1e0bfb3274bb1d76398909e8a62d612d1e5c02b3418b880f03ee0fa8f1153

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page