Binance API Example - Google Sheets Integration Tutorial
文章推薦指數: 80 %
How to import crypto data from Binance into Google Sheets using the Binance API. Step-by-step tutorial for beginners. APIIntegrationTutorials BinanceAPIExample–GoogleSheetsIntegrationTutorial By ApiphenyTeam CryptoAPItutorialsandmore: Tutorials:Binance|Bitfinex|Bitmex|BscScan|Cardano|Coinbase|Coingecko|Coinmarketcap|CoinAPI|Coinranking|Etherscan|FTX|Glassnode|Huobi|LiveCoinWatch|Kraken|Kucoin|Messari|Nomics|OpenSea|PancakeSwap|Rarible|Rarify|SolanartBestCryptoAPIs:listofthebestAPIsforcryptocurrencytradersanddevsCoinStats:portfoliotrackingappthatworkswith100+walletsandexchanges HowtoconnectBinancetoGoogleSheets Binanceisoneoftheworld’smostpopularcryptocurrencyexchanges,andtheirAPIisoneofthemostpopularcryptoexchangeAPIs.Ifyouhaven’tsignedupforBinanceyet,clickheretosignupandregisteranewaccount. WecanuseBinance’sAPItoimportdatafromBinanceintoGoogleSheets.Inthistutorial,you’lllearnhowtoconnecttheBinanceRESTAPItoGoogleSheetsin5stepsusingtheApiphenyAPIadd-on: InstalltheApiphenyAdd-onChooseyourBinanceAPIendpointEnteryourBinanceAPIrequestintoApipheny Step1.)InstallandopentheApiphenyadd-onforGoogleSheets ApiphenyisanAPIconnectorforGoogleSheets.YoucanuseApiphenytoconnectyourGoogleSheetstounlimitedAPIdatasources,makeunlimitedAPIrequests,andmore.Thereisa30dayfreetrialincluded. 1.) InstallApiphenybyopeningthefollowinglinkondesktopandthenclickingtheInstallbuttonintheGoogleMarketplace:https://apipheny.io/install 2.)Afteryou’veinstalledApipheny,openaGoogleSheetandthenclickontheExtensionsdropdowninthemenuatthetop. InthedropdownlistyoushouldseeApipheny.ClickApiphenythenclickImportAPItoopentheApiphenysidebarinyourGoogleSheet. Tip:youcanopenanewGoogleSheetbyenteringthisURLinyourbrowser:sheet.new Step2.)ChooseaBinanceAPIendpoint AnendpointisanAPIURLthatreturnsthespecificdatayouwantfromBinance.InthissectionweshowyouhowtobrowsetheBinanceAPIdocumentationtofindtheURLthatreturnsthespecificdatayouneed.Ifyou’dliketoseespecificexamplesofURLsyoucanuse,justskiptothenextsection. TobrowseendpointURLsandqueryrequirements,gotheBinanceAPIdocumentationpagehere:https://binance-docs.github.io/apidocs/spot/en/#general-info AllBinanceendpointURLsarecreatedbyappendinganendpoint-specificpathtotherootURL: https://api.binance.com IfyouareexperiencingproblemswiththeaboveAPIroot,pleaseuseanalternateasoutlinedinthe generalAPIinformation sectionoftheofficialBinancedocumentation. Inthistutorial,wewilldiscusstwotypesofendpointsavailablefromtheBinanceAPI: Endpointsthatdonotrequireauthentication(Publicendpoints)Endpointsthatdorequireauthentication(Signedendpoints) Thistutorialcovershowtousethepublicendpointsthatdonotrequireauthentication.TheonlycategoryfromtheBinanceAPIdocumentationthathaspublicendpointswhichrequirenoAPIkeyistheMarketDataEndpoints:https://binance-docs.github.io/apidocs/spot/en/#market-data-endpoints SignedBinanceAPIendpointsthatrequireHMACSHA256willnotcurrentlyworkwithApipheny,butendpointsthatdonotrequireHMACSHA256willwork.SomeBinanceAPIendpointsrequireHMACSHA256andothersdon't.Thereasonsignedendpointsdon'tcurrentlyworkwithourappisbecausetheyrequireanadditionalparametercalledsignature,akeyedHMACSHA256signaturewithyoursecretKeyasthekey,andaconcatenationofallthequery’sparametersasthevaluepassedtotheHMACoperation.SignedendpointsalsorequireatimeStampparameter,populatedwiththerequest’smillisecondtimestamp.Youcantellifanendpointissignedornotbecausewhenyoulookatthedocumentationforthatendpoint,itwillsay(HMACSHA256)nexttotheURL,asseeninthescreenshotbelow: Onceyou’velookedthroughtheBinanceAPIdocumentationandchosenapublicendpointyouwanttouse,youcangoaheadandentertheURLintoApiphenyandrunyourrequest.Inthenextsectionwecovermakingarequestinmoredetailalongwithsomeexamplerequests. Alltimeandtimestamprelatedfieldsarein milliseconds.Youcanusehttps://timestamp.online/toconvertthedateyouwantintomilliseconds. Step3.)EnteryourBinanceAPIrequestintoApipheny Inthissectionwewillshowyousomeexamplerequestsusingthepublicendpoints.PublicendpointscanbeaccessedwithoutanAPIkey.Inthesectionabovewediscussedhowtodeterminewhetheranendpointispublicornot. TheonlycategoryfromtheBinanceAPIdocumentationthathaspublicendpointswhichrequirenoAPIkeyistheMarketDataEndpoints:https://binance-docs.github.io/apidocs/spot/en/#market-data-endpoints MarketDataEndpointsCategory AnexamplepublicendpointisSymbolPriceTicker,whichgetsthelatestpriceforoneormultiplesymbols.ItusestheGETmethodandtheURLforthisendpointis: https://api.binance.com/api/v3/ticker/price Tousethisendpointoranyotherpublicendpoint,justcopyandpastetheURLintotheApiphenyadd-on,thenclicktheRunbuttonatthebottomoftheadd-onandthedatawillbeimportedintoyourGoogleSheet,likeso: SymbolPriceTickerEndpoint Morepublicendpointexamples TheCheckServerTimeendpointtestsconnectivitytotheRestAPIandgetsthecurrentservertime.TheURLforthisendpointis: Method:GET APIURL:https://api.binance.com/api/v3/time TheOrderBookendpointprovidesalistingoftheongoingordersinthesystem.TheURLforthisendpointis: Method:GET APIURL:https://api.binance.com/api/v3/depth?symbol=your_symbol Whenusingthisendpoint,don’tforgettoreplaceyour_symbolwithanactualsymbol. TheSymbolOrderBookTickerendpointgetsthelatestordersforoneormultiplesymbols.TheURLforthisendpointis: Method:GET APIURL:https://api.binance.com/api/v3/ticker/bookTicker TheRecentTradesListendpointreturnsalistofmostrecenttradesontheplatform.TheURLforthisendpointis: Method:GET APIURL:https://api.binance.com/api/v3/trades?symbol=your_symbol Don’tforgettoreplaceyour_symbolwithanactualsymbol. TheCompressed/AggregateTradesListendpointthatgetscompressed,aggregatetrades.Tradesthatfillatthetime,fromthesameorder,withthesamepricewillhavethequantityaggregated. Method:GET APIURL:https://api.binance.com/api/v3/aggTrades The24hrTickerPriceChangeStatisticsendpointthatgets24hourrollingwindowpricechangestatistics. Careful whenaccessingthiswithnosymbol. Method:GET APIURLPath:https://api.binance.com/api/v3/ticker/24hr Authenticatedendpoints Therearecurrently1ormoreendpointsthatrequireanAPIkeybuttheydon’trequireHMACSHA256whichmeanstheywillworkwithApipheny.ToobtainanAPIkey,followtheinstructionsbelow.Ifyoualreadyhaveyourkeyyoucanskipthissection. 1.AfterloggingintoyourBinanceaccount,clickAPIManagementintheusercenterdrop-downbox: BinanceAccountDashboard 2.Ifyoudidnotinstall2-factorauthentication(2FA)whencreatingyourBinanceaccount,youwillbeaskedtodoadd2FAatthispoint: ChooseBetweenGoogleAuthenticationandSMSAuthentication InthisexampleIchoseSMSAuthentication.ClicktheSendSMSbuttontoreceiveacodeonyourmobilephone.Afteryouhavereceivedthecode,enteritintheSMSVerificationCodesection.YoucanalsochooseGoogleAuthentication,whichismoresecure.Afteryouadd2FA,thispopupwilldisappearandyoucancontinueobtainingyourAPIkey. Two-FactorAuthentication 3.WhentheAPImanagementpagefinallyopens,enteraname(label)foryourprivateAPIkey,andthenclicktheCreatebutton: CreateaLabelForYourAPIKey 4.Next,fillintheGoogleAuthenticationCodeorSMSAuthenticationCodeagain,toconfirmtheAPIKeycreationforyouraccount: SMSorGoogleAuthenticationCode 5.Onceyouhavepassedthe2FAAuthentication,thesystemwillsendaconfirmationemailtotheemailaddressofyourBinanceaccount.YoucangodirectlytoyouremailorclicktheGotoemailandverifybuttonontheBinancepage: ConfirmationEmail 6.Intheemail,clicktheConfirmnewAPIkeybutton: APIKeyConfirmation 7.OnthenextpageyouwillseeyourAPIkeyandSecretkey.RemembertocopyandpasteyourSecretKeysomewheresafe,asitwillnotbeshownagain,duetosecurityreasons.IfyouforgettheSecretKey,youwillneedtodeletetheAPIkeyandthencreateanewone. APIKeyandSecretKeySection NowthatyouhaveyourAPIkey,youcanenteryourAPIrequestintoApipheny. Afteryou’vefoundtheendpointyouneed,copythecompleteURLintotheAPIURLPathfieldintheApiphenyadd-on. Here’sanexampleendpointthatrequiresanAPIkey: https://api.binance.com/sapi/v1/margin/allPairs AfteryouenteryourURLintoApipheny,you’llneedtoenteracoupleheaders. IntheHeaderssectionofApipheny,addtworowswiththefollowingkeysandvalues: Header1Key: Accept Header1Value: application/json Header2Key: X-MBX-APIKEY Header2Value: your-API-key your-API-keyisthevalueyougotinthestepswecoveredabove. Here’swhatyourAPIrequestshouldlooklikewiththeAPIURLandheadersenteredinApipheny: InserttheAPIURLandHeadersIntoApipheny OnceyouhavetheURLandheadersentered,thelaststepistoclicktheRunbuttonatthebottomoftheApiphenyadd-onandthenwaitfortheBinanceAPIdatatobeimportedintoyourGoogleSheet. BinanceAPIDatainGoogleSheets Moreauthenticatedendpointexamples TheQueryMarginAsset(MARKET_DATA)endpoint: Method:GET APIURLPath:https://api.binance.com/sapi/v1/margin/asset Headers: Header1Key: X-MBX-APIKEY Header1Value: your-API-key Makesuretoreplaceyour-API-keywiththeAPIkeyyoupreviouslyobtained. TheQueryCrossMarginPairendpoint: Method:GET APIURLPath:https://api.binance.com/sapi/v1/margin/pair Headers: Header1Key: X-MBX-APIKEY Header1Value: your-API-key Makesuretoreplaceyour-API-keywiththeAPIkeyyoupreviouslyobtained. ApiphenyFeatureTutorials MakeaGETrequestMakeaPOSTrequestPUT,PATCH,&DELETERequestsSaverequestsforlaterSchedulerequestsforautomaticupdatesReferencecellvaluesinrequests=APIPHENYcustomfunctionStackmultipleURLsinasinglerequestRunallsavedrequestsatonceModifyyourrequestsettingsImport&exportsavedAPIsettings InstallApiphenyHere CryptoAPItutorialsandmore: Tutorials:Binance|Bitfinex|Bitmex|BscScan|Cardano|Coinbase|Coingecko|Coinmarketcap|CoinAPI|Coinranking|Etherscan|FTX|Glassnode|Huobi|LiveCoinWatch|Kraken|Kucoin|Messari|Nomics|OpenSea|PancakeSwap|Rarible|Rarify|SolanartBestCryptoAPIs:listofthebestAPIsforcryptocurrencytradersanddevsCoinStats:portfoliotrackingappthatworkswith100+walletsandexchanges APITutorials AhrefsAPIAirtableAPIAlphaVantageAPIAsanaAPIBinanceAPIClickupAPICoingeckoAPICoinmarketcapAPICoinbaseAPIConstantContactAPIDiscordAPIDriftAPIEtsyAPIEventbriteAPIFacebookGraphAPIFacebookAdsAPIFigmaAPIGithubAPIGoogleSERPAPIHubspotAPIHunterAPI InstagramAPIIntercomAPIJIRAAPILinkedinAPILinkedinAdsAPIMailchimpAPIMondayAPIMinecraftAPIPaypalAPIPipedriveAPIProductHuntAPIQuickbooksAPIRedditAPIRedditAdsAPIRiotGamesAPISalesforceAPIShipstationAPIShopifyAPISlackAPISnapchatAPISpotifyAPI SquareAPISquarespaceAPIStripeAPISurveyMonkeyAPITableauAPITikTokAPITrelloAPITwitchAPITwitterAPITypeformAPIVideoaskAPIWeatherDataAPIWebflowAPIWikipediaAPIWoocommerceAPIWordPressAPIYelpAPIYoutubeAPIZendeskAPIZillowAPIZoomAPI ViewAllTutorials BrowseAPICourses APIKnowledge WhatisanAPI?WhatisanAPIURL?Whatareparameters?Whatisanendpoint?WhatisanAPIkey/token?Whatisbasicauthentication?Whatareheaders?WhatisaGETrequest?WhatisaPOSTrequest? share: TAGS:BinanceAPIcryptocurrencyapisdataapisfinanceapis APIBasics WhatisanAPI? WhatisanAPIURL? Whatareparameters? Whatisanendpoint? WhatisanAPIkey/token? Whatareheaders? WhatisaGETrequest? WhatisaPOSTrequest? ApiphenyFeatures MakeaGETrequest MakeaPOSTrequest PUT,PATCH,&DELETErequests Saverequests Schedulerequests Referencecellvalues =APIPHENYformula StackmultipleURLs Runallrequestsatonce Modifyrequestsettings Import&exportrequests ApiphenyDemo https://www.youtube.com/watch?v=KE71XJP6o2ENFTAPIDemohttps://www.youtube.com/watch?v=bEBo63ckx-kCryptoAPIDemohttps://www.youtube.com/watch?v=irfrkYjHe28StockAPIDemohttps://www.youtube.com/watch?v=SelNmGGmEQg
延伸文章資訊
- 1binance-official-api-docs/rest-api.md at master - GitHub
Official Documentation for the Binance APIs and Streams - binance-official-api-docs/rest-api.md a...
- 2API | Binance Support
資深數字貨幣交易用戶可以在這裏了解如何更加快捷地使用幣安API進行交易.
- 3Binance APIs
API trading provides a testing environment, API documentation, and Sample Code in 6 languages. Su...
- 4Welcome to python-binance v1.0.16 — python-binance 0.2.0 ...
This is an unofficial Python wrapper for the Binance exchange REST API v3. I am in no way affilia...
- 5Binance API Import - CoinTracking
This function checks your Binance trades and transfers them automatically into your CoinTracking ...