Binance API Example - Google Sheets Integration Tutorial

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?