I am trying to get account information by using requests library with the code below.
enter image description here
import requests
url = 'https://api.binance.com'
api_get_info = '/sapi/v1/accountSnapshot'
hmac_sha256 = 'api_key'
get_account_info = requests.get(url+api_get_info+api_get_info)
print(get_account_info.text)
I have no idea what the url should be like. Could you guys please give me some idea :)
Binance has an official GitHub repository with examples about these signatures, you can check it out over here: https://github.com/binance/binance-signature-examples/blob/master/python/spot/spot.py
See the function send_signed_request() at the bottom of that file.
Related
I am working on a project that scrapes multiple YouTube channels display name, creation date, subscriber count, and view count. I need help creating this project because I can't seem to find anything about it. I have a YouTube API Key and I just can't seem to find anything about this.
It's a little hard to work with the sample code that the YouTube api shows. Use the curl section. Then send a request to the link that shows and use the information. for example send http request to this:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[Channel ID]&key=[Your API]
and this address give you JSON file and you can get what you want!.
for example you can see subscribe count from channel list section in youtube api document. like this image.
you can find other things with this way!. good luck :)
also you can use this.
i'm making sample for you.
def subscribeCount(channel_id):
API = f"https://youtube.googleapis.com/youtube/v3/channels?part=statistics&id={channel_id}&key=[Enter Your Api Key]"
json_data = requests.get(API).json()
subscribeCount = json_data['items'][0]['statistics']['subscriberCount']
return subscribeCount
this sample need channel id(Like all other sections xD). and api key you Which you got from the google developer console.It then shows you the number of subscriptions to a channel. The rest of the sections work the same way.
Read the following article for more information.
How to Use the Python Requests Module With REST APIs
I know this has been posted about multiple times but I've tried all the solutions I've found on SO and none have worked. I'm trying to retrieve user data about myself from Spotify's Web API by following simple examples like the ones posted here and here. So I've now tried both Spotify and tekore but neither are working for me.
The closest I've come to making it work is by following this example. When I run that code in a Jupyter Notebook, a separate window pops open and prompts me to agree to authorize access to my data. When I select "Agree" I get an "ERR_TOO_MANY_REDIRECTS" error and the suggestion to clear my cookies, which I've done multiple times now.
And when I enter my redirect URI in the prompt that pops up in the notebook, I get the following error: "KeyError: 'Passed URL contains no parameter code!'"
I am using "http://localhost:8888/callback/" as the redirect URI and I've double-checked to make sure the whitelisted URI matches what I'm using in my notebook. Any suggestions as to what I'm doing wrong?
Lastly, here's the code I'm trying:
import tekore as tk
# Read in keys
client_id = open('./spotify-client-id.txt', 'r').read().rstrip('\n')
client_secret = open('./spotify-client-secret.txt', 'r').read().rstrip('\n')
# Set URI
redirect_uri = 'http://localhost:8888/callback/'
conf = (client_id, client_secret, redirect_uri)
token = tk.prompt_for_user_token(*conf, scope=tk.scope.every)
spotify = tk.Spotify(token)
tracks = spotify.current_user_top_tracks(limit=10)
spotify.playback_start_tracks([t.id for t in tracks.items])
Apparently the trick is to ignore the error message, copy the URL from the browser, and paste it into the cell in your Jupyter Notebook.
spotipy should cache the response so that you don't have to go through this process each time. Thanks to murraypaul on Spotify's Community help forum for this advice.
i am creatin a project which includes integrating some major Video Network in Python.. My Main Objective is to make people search public videos by input keywords. I have done foe Youtube and now i want something similar with Vimeo but i don't get any idea on how there URI Request works.. As for Youtube i used the below codes to make a video search through the API..
import requests
def browse_video_by_keyword(search , pageToken):
_KEY = 'AIzaSyAlpM2iiTfLFUvEs3dR5IsHKX-wOJzh_uo'
url = 'https://www.googleapis.com/youtube/v3/search?key={api_key}&part=snippet,id&pageToken={page}&maxResults=24&q={keyword}'
request = requests.get(url.format(api_key=_KEY , keyword=search , page=pageToken))
res = request.json()
return res["items"];
I Need someone to give me idea on how i can do something similar to this for Vimeo API.. I have search through very where i can but no get any idea.. Any Help would be appreciated. Thanks In advance..
Looking at Vimeo API documentation, I think you need to hit their "Search for videos" end point. You can read more on it here
I am using python to get info data from facebook api.
I use the following code:
import facebook
import requests
token = 'mytoken'
graph = facebook.GraphAPI(token)
profile=graph.get_object("me")
but only the name and the id are returned. Thus i cannot use the command
profile["gender"]
in order to get the user's gender.
How can i fix that?
thank you!!
I'm trying to set up the Twitter API to change a Twitter account display picture and description. After setting the API keys and telling it to do it's magic, I can get through without any errors, except after checking the Twitter account and finding none of my changes applied. I've tried various different methods by sending the most simple descriptions and pictures through the API but still got nothing. What is it I'm doing wrong? Any help is appreciated!
import twitter
twitterAPI = twitter.Api(consumer_key=twitterConsumerKey,
consumer_secret=twitterConsumerSecret,
access_token_key=twitterAccessToken,
access_token_secret=twitterAccessTokenSecret,
)
twitter.User().SetProfileImageUrl("http://website.com/image.jpg")
twitter.User().SetDescription("Hello there")
Try this:
twitterAPI.User().SetProfileImageUrl("http://website.com/image.jpg")
twitterAPI.User().SetDescription("Hello there")
You are calling the module instead of the object.
Switched over to using Tweepy, as python-twitter doesn't actually have the ability to change the description or profile image.