{"id":8755,"date":"2021-04-06T18:05:29","date_gmt":"2021-04-06T18:05:29","guid":{"rendered":"http:\/\/algotrading101.com\/learn\/?p=8755"},"modified":"2023-04-03T21:10:33","modified_gmt":"2023-04-03T21:10:33","slug":"gemini-api-guide","status":"publish","type":"post","link":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/","title":{"rendered":"Gemini API &#8211; A Step-by-Step Guide"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div><p id=\"pvc_stats_8755\" class=\"pvc_stats total_only  \" data-element-id=\"8755\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p><div class=\"pvc_clear\"><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"603\" height=\"129\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/gemini-hor-dark-full-rgb@3x.jpg\" alt=\"\" class=\"wp-image-16204\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/gemini-hor-dark-full-rgb@3x.jpg 603w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/gemini-hor-dark-full-rgb@3x-300x64.jpg 300w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Table of contents:<\/h3>\n\n\n\n<ol><li><a href=\"#what-is-gemini-api\">What is Gemini API?<\/a><\/li><li><a href=\"#what-is-gemini-exchange\">What is Gemini?<\/a><\/li><li><a href=\"#what-is-the-gemini-dollar\">What is the Gemini Dollar?<\/a><\/li><li><a href=\"#is-gemini-free\">Is Gemini free?<\/a><\/li><li><a href=\"#why-should-i-use-gemini\">Why should I use Gemini?<\/a><\/li><li><a href=\"#why-shouldnt-i-use-gemini\">Why shouldn\u2019t I use the Gemini?<\/a><\/li><li><a href=\"#is-gemini-available-in-my-country\">Is Gemini available in my country?<\/a><\/li><li><a href=\"#what-are-the-alternatives-to-using-gemini\">What are the alternatives to using Gemini API?<\/a><\/li><li><a href=\"#what-clients-are-available-for-the-gemini-api\">What clients are available for the Gemini API?<\/a><\/li><li><a href=\"#how-to-get-started-with-gemini\">How to get started with Gemini API?<\/a><\/li><li><a href=\"#what-are-geminis-public-apis\">What are Geminis\u2019 Public APIs?<\/a><ol><li><a href=\"#how-to-get-price-data-on-gemini\">How to get Price Data on Gemini API?<\/a><\/li><li><a href=\"#how-to-access-technical-indicators-such-as-the-20sma-with-the-gemini-api\">How to access technical indicators such as the 20 SMA with the Gemini API?<\/a><\/li><\/ol><\/li><li><a href=\"#how-to-place-orders-with-gemini\">How to place orders with Gemini API?<\/a><ol><li><a href=\"#example-one\">How to execute a trade on ETH when BTC hits a certain price with the Gemini API?<\/a><\/li><li><a href=\"#example-two\">How to execute an ETH trade when BTC moves 5% in the last 5 minutes with the Gemini API?<\/a><\/li><li><a href=\"#how-to-cancel-orders-with-gemini\">How to cancel orders with Gemini API?<\/a><\/li><li><a href=\"#what-order-execution-options-does-gemini-have\">What order execution options does Gemini API have?<\/a><\/li><\/ol><\/li><li><a href=\"#how-to-get-notional-and-trade-volumes-with-gemini\">How to get Notional and Trade Volumes with Gemini API?<\/a><\/li><li><a href=\"#how-to-use-gemini-clearing-orders\">How to use Gemini Clearing orders?<\/a><\/li><li><a href=\"#how-to-use-fund-management-apis-from-gemini\">How to use Fund Management APIs from Gemini?<\/a><\/li><li><a href=\"#what-is-the-heartbead-function-from-gemini\">What is the Heartbeat function from Gemini API?<\/a><\/li><li><a href=\"#about-gemini-exchange\">More about Gemini<\/a><\/li><li><a href=\"#full-code\">Full code<\/a><\/li><\/ol>\n\n\n\n<a name=\"what-is-gemini-api\">\n\n\n\n<h2 class=\"wp-block-heading\">What is Gemini API?<\/h2>\n\n\n\n<p>Gemini API is a method that allows us to automatically trade cryptocurrencies on Gemini via code.<\/p>\n\n\n\n<p>Link: <a href=\"https:\/\/www.gemini.com\">https:\/\/www.gemini.com<\/a><\/p>\n\n\n\n<a name=\"what-is-gemini-exchange\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is Gemini?<\/strong><\/h2>\n\n\n\n<p>Gemini is a US-based cryptocurrency exchange platform that allows its users to safely buy, sell, and create portfolios around crypto.<\/p>\n\n\n\n<p>Gemini was created in 2014 in New York by the Winklevoss twins. This makes Gemini one of the few crypto exchanges that are regulated in the US.<\/p>\n\n\n\n<p>Gemini brings a user-friendly platform that is great for beginners and advanced traders alike. For example, beginner traders will enjoy Gemini\u2019s web and mobile apps while the advanced users may dive into advanced features that the Active Trader brings.<\/p>\n\n\n\n<a name=\"what-is-the-gemini-dollar\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is the Gemini Dollar?<\/strong><\/h2>\n\n\n\n<p>The Gemini Dollar (GUSD) is a regulated stablecoin that is designed for spending, lending and trading. It is also supported by the US dollars held at State Street Bank and Trust Company.<\/p>\n\n\n\n<p>This means that it can be transferred back to US dollars at any time with a 1:1 rate.<\/p>\n\n\n\n<a name=\"is-gemini-free\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Is Gemini free?<\/strong><\/h2>\n\n\n\n<p>Gemini offers various fee schedules that are dependent on the platform you use. Most traders tend to use their web and mobile platforms, so the fees for those look like the following:<\/p>\n\n\n\n<p>Less than $10 \/ fee $0.99<\/p>\n\n\n\n<p>More than $10 but less than $25 \/ fee $1.49<\/p>\n\n\n\n<p>More than $25 but less than $50 \/ fee $1.99<\/p>\n\n\n\n<p>$50.01 to $200 \/ fee $2.99<\/p>\n\n\n\n<p>More than $200 \/ fee 1.49% of your total order value<\/p>\n\n\n\n<p>You will also be charged a convenience fee of 0.50% of the current market price of the coin that you are buying, on top of the transaction fee.<\/p>\n\n\n\n<p>The API usage fees are more complicated so I would advise the reader to visit the following link for a better look where all the calculations are shown with examples:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.gemini.com\/fees\/api-fee-schedule#section-api-fee-schedule\">https:\/\/www.gemini.com\/fees\/api-fee-schedule#section-api-fee-schedule<\/a><\/p>\n\n\n\n<a name=\"why-should-i-use-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why should I use Gemini?<\/strong><\/h2>\n\n\n\n<ul><li>Easy to use and beginner-friendly<\/li><li>Has high-security protocols and hot wallets<\/li><li>Provides many platforms that can accommodate the trader&#8217;s skill<\/li><li>Provides educational resources<\/li><li>Has a mobile app<\/li><li>Has a sandbox for API testing<\/li><li>You can pay directly with your crypto<\/li><\/ul>\n\n\n\n<a name=\"why-shouldnt-i-use-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why shouldn\u2019t I use Gemini?<\/strong><\/h2>\n\n\n\n<ul><li>Not available in all countries<\/li><li>Limited account funding methods<\/li><li>High fees<\/li><li>Only offers cryptocurrency trading<\/li><\/ul>\n\n\n\n<a name=\"is-gemini-available-in-my-country\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Is Gemini available in my country?<\/strong><\/h2>\n\n\n\n<p>As the Gemini API is not available in all countries I created a map of all Gemini supported countries so you don&#8217;t need to go over a boring list.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"428\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/dfdfasfa-1024x428.jpg\" alt=\"\" class=\"wp-image-16206\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/dfdfasfa-1024x428.jpg 1024w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/dfdfasfa-300x125.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/dfdfasfa-768x321.jpg 768w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/dfdfasfa.jpg 1521w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<a name=\"what-are-the-alternatives-to-using-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What are the alternatives to using Gemini<\/strong> API<strong>?<\/strong><\/h2>\n\n\n\n<p>Gemini API can be replaced with some alternatives and they are the following:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/algotrading101.com\/learn\/coinbase-api-guide\/\">Coinbase<\/a><\/li><li><a href=\"https:\/\/algotrading101.com\/learn\/binance-python-api-guide\/\">Binance<\/a><\/li><li><a href=\"https:\/\/algotrading101.com\/learn\/bitmex-api-guide\/\">BitMex<\/a><\/li><li>Kraken.io<\/li><li>CoinGate<\/li><li>CoinPaymets<\/li><li>GoCoin<\/li><li>Coinomi<\/li><li>Cryptopay<\/li><li>Blocknomics<\/li><li>Blockchain<\/li><li>BitPay and more\u2026<\/li><\/ul>\n\n\n\n<a name=\"what-clients-are-available-for-the-gemini-api\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What clients are available for the Gemini API?<\/strong><\/h2>\n\n\n\n<p>Gemini API is available in the following clients:<\/p>\n\n\n\n<ul><li>Python<\/li><li>JavaScript<\/li><li>Java<\/li><li>Ruby<\/li><li>TypeScript<\/li><li>C#<\/li><li>Go<\/li><li>PHP<\/li><\/ul>\n\n\n\n<a name=\"how-to-get-started-with-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to get started with Gemini API?<\/strong><\/h2>\n\n\n\n<p>In order to get started with the Gemini API, you will first need to go over to their website that is found on the following link:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.gemini.com\/\">https:\/\/www.gemini.com\/<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"442\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/4-15-1024x442.jpg\" alt=\"\" class=\"wp-image-16207\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/4-15-1024x442.jpg 1024w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/4-15-300x129.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/4-15-768x331.jpg 768w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/4-15-1536x663.jpg 1536w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/4-15.jpg 1863w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The next thing will be to sign up. For this, click on the \u201cGet Started\u201d icon and the Gemini will take you through the sign up process. Be prepared to give a lot of personal information such as your phone number and ID card as Gemini is a US regulated exchange.<\/p>\n\n\n\n<p>For the purpose of this article, I will use Gemini\u2019s sandbox environment that is aimed for API testing. It has a separate sign up process so let\u2019s go over it together.<\/p>\n\n\n\n<p>The first thing to do is to visit the following link that will take us to the sign up screen:<\/p>\n\n\n\n<p><a href=\"https:\/\/exchange.sandbox.gemini.com\/\">https:\/\/exchange.sandbox.gemini.com\/<\/a><\/p>\n\n\n\n<p>There you will simply inter your first and last name, email and password.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"614\" height=\"909\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/3-11.jpg\" alt=\"\" class=\"wp-image-16208\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/3-11.jpg 614w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/3-11-203x300.jpg 203w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><\/figure>\n\n\n\n<p>After completion you will need to enter in your phone number for the verification step. After entering the SMS code, you will be brought to a screen that looks like the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"516\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/5-15-1024x516.jpg\" alt=\"\" class=\"wp-image-16209\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/5-15-1024x516.jpg 1024w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/5-15-300x151.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/5-15-768x387.jpg 768w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/5-15-1536x773.jpg 1536w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/5-15.jpg 1899w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Click on your account icon that is found in the upper-right corner and go to settings. Then navigate the newly opened tab to the API icon that is found on the left side:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"277\" height=\"710\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/6-15.jpg\" alt=\"\" class=\"wp-image-16210\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/6-15.jpg 277w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/6-15-117x300.jpg 117w\" sizes=\"(max-width: 277px) 100vw, 277px\" \/><\/figure>\n\n\n\n<p>When there, click the \u201cCREATE A NEW API KEY\u201d button. A pop-up will prompt you to enter a key that was sent to your phone via SMS. After entering it you will state what kind of an API Key you want.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"508\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/7-12.jpg\" alt=\"\" class=\"wp-image-16211\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/7-12.jpg 991w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/7-12-300x154.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/7-12-768x394.jpg 768w\" sizes=\"(max-width: 991px) 100vw, 991px\" \/><\/figure>\n\n\n\n<p>You can pick either the Master or Primary API Key option. The main difference between them is that the Master API Key has more options in terms of regulation between your accounts. I will pick this one. <\/p>\n\n\n\n<p>Then you will be presented with your API Key and API Secret. Be sure to safely store them as you won\u2019t see them again. Also, don&#8217;t forget to name your API Key and give it permissions in the API Key Settings.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"690\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/8-14.jpg\" alt=\"\" class=\"wp-image-16212\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/8-14.jpg 825w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/8-14-300x251.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/8-14-768x642.jpg 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"166\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/9-12-1024x166.jpg\" alt=\"\" class=\"wp-image-16213\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/9-12-1024x166.jpg 1024w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/9-12-300x49.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/9-12-768x125.jpg 768w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/9-12.jpg 1361w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>All done. Now, let us install the python library for the Gemini API using the following command:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>pip install gemini_python<\/code><\/pre><\/div>\n\n\n\n<a name=\"what-are-geminis-public-apis\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What are Gemini\u2019s Public APIs?<\/strong><\/h2>\n\n\n\n<p>The Gemini API offers us the following public APIs to use:<\/p>\n\n\n\n<ul><li>Symbols<\/li><li>Tickers<\/li><li>Candles<\/li><li>Current Order Books<\/li><li>Trade History<\/li><li>Current auction<\/li><li>Auction history<\/li><li>Price feed<\/li><\/ul>\n\n\n\n<p>Let us explore how to call each of them and see what the responses look like and how we can manipulate them for a better understanding and look.<\/p>\n\n\n\n<p>Have in mind that the rate limit for the public API entry points is set to 120 requests per minute, while the private API entry points are set to 600 requests per minute.<\/p>\n\n\n\n<p>As their python library is experiencing some issues with connecting to the WebSocket, we will do the calls manually.<\/p>\n\n\n\n<p>Let us import the relevant libraries and obtain a list of all the symbols that the Gemini API offers:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import json, requests\nimport pandas as pd<\/code><\/pre><\/div>\n\n\n\n<p>Now we will create a base for our URL that will remain the same for some of our public API endpoints. After that, we will build our response by adding the symbols specification to the end of the main URL.<\/p>\n\n\n\n<p>We will also specify the response format to be JSON and then pass it into a pandas data frame and look at the last five of them.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>base_url = &quot;https:\/\/api.gemini.com\/v1&quot;\nresponse = requests.get(base_url + &quot;\/symbols&quot;)\nsymbols = pd.DataFrame(response.json())\nsymbols.tail()<\/code><\/pre><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"178\" height=\"268\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/11-15.jpg\" alt=\"\" class=\"wp-image-16214\"\/><\/figure><\/div>\n\n\n<p>Now, let us check the value for a specific symbol, in this case it will be the BTC-USD one. All we need is to change our response to accommodate the wished symbol.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>response = requests.get(base_url + &quot;\/symbols\/details\/BTCUSD&quot;)\nsymbols = response.json()\nsymbols<\/code><\/pre><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>{'symbol': 'BTCUSD',\n 'base_currency': 'BTC',\n 'quote_currency': 'USD',\n 'tick_size': 2,\n 'quote_increment': 8,\n 'min_order_size': '0.00001',\n 'status': 'open'} <\/code><\/pre>\n\n\n\n<a name=\"how-to-get-price-data-on-gemini\">\n\n\n\n<p>The next thing we want to check for is the information about the recent trading activity of our symbol. For this, we will use the ticker endpoint.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>response = requests.get(base_url + &quot;\/pubticker\/btcusd&quot;)\nbtc_data = response.json()\nbtc_data<\/code><\/pre><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>{'bid': '35910.14',\n 'ask': '35918.91',\n 'volume': {'BTC': '4540.3648977187',\n   'USD': '159213478.551186081629',\n   'timestamp': 1609970400000},\n 'last': '35918.91'}<\/code><\/pre>\n\n\n\n<p>In order to get the V2 ticker we can do the following:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>base_url = &quot;https:\/\/api.gemini.com\/v2&quot;\nresponse = requests.get(base_url + &quot;\/ticker\/btcusd&quot;)\nbtc_data = response.json()\nbtc_data<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"307\" height=\"780\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/14-13.jpg\" alt=\"\" class=\"wp-image-16215\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/14-13.jpg 307w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/14-13-118x300.jpg 118w\" sizes=\"(max-width: 307px) 100vw, 307px\" \/><\/figure>\n\n\n\n<p>What if we want to obtain the 15min time-interval data for our symbol aka candles?<\/p>\n\n\n\n<p>In order to do this, we will need to change several things. Firstly, we will change our parameters. After that, we will arrange the data into a pandas data frame and provide a name for each column of the response.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>response = requests.get(base_url + &quot;\/candles\/btcusd\/15m&quot;)\nbtc_candle_data = pd.DataFrame(response.json(), columns =[&#39;time&#39;,&#39;open&#39;,&#39;high&#39;,&#39;low&#39;,&#39;close&#39;,&#39;volume&#39;])<\/code><\/pre><\/div>\n\n\n\n<p>The next thing is to convert the unix timestamp to a normal date and pass it as an index value. As the historical data will be arranged in a descending order starting from our current timestamp, we will need to rearrange it.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>btc_candle_data[&#39;time&#39;] = pd.to_datetime(btc_candle_data[&#39;time&#39;], unit=&#39;ms&#39;)\nbtc_candle_data.set_index(&#39;time&#39;, inplace=True)\nbtc_candle_data.sort_values(by =[&#39;time&#39;], inplace = True)\nbtc_candle_data<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"719\" height=\"564\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/15-10.jpg\" alt=\"\" class=\"wp-image-16216\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/15-10.jpg 719w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/15-10-300x235.jpg 300w\" sizes=\"(max-width: 719px) 100vw, 719px\" \/><\/figure>\n\n\n\n<a name=\"how-to-access-technical-indicators-such-as-the-20sma-with-the-gemini-api\">\n\n\n\n<p>Now, let us calculate the 20 day simple moving average (20SMA). This step can be done easily with pandas but for more advanced indicators such as the RSI, I\u2019d advise using the btalib library.<\/p>\n\n\n\n<p>With pandas the code for the 20SMA looks like this<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>btc_candle_data[&#39;20 SMA&#39;] = btc_candle_data.close.rolling(20).mean()<\/code><\/pre><\/div>\n\n\n\n<p>With btalib:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>btc_candle_data[\u201920 SMA\u2019] = btalib.sma(btc_candle_data.close, period=20).df\nbtc_candle_data.tail()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"281\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/16-9.jpg\" alt=\"\" class=\"wp-image-16217\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/16-9.jpg 830w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/16-9-300x102.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/16-9-768x260.jpg 768w\" sizes=\"(max-width: 830px) 100vw, 830px\" \/><\/figure>\n\n\n\n<p>If you want to save the dataset into a csv format do the following:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>btc_candle_data.to_csv(&#39;BitcoinData.csv&#39;)<\/code><\/pre><\/div>\n\n\n\n<p>Now, let\u2019s go for a juicy candlestick plot to get a better understanding of the data. For this, we will use Plotly that provides us with interactive charts for finance.<\/p>\n\n\n\n<p>All we need to do is to specify the type of graph and its components that build the main graph figure.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>fig = go.Figure(data=[go.Candlestick(x = btc_candle_data.index,\n                                    open = btc_candle_data[&#39;open&#39;],\n                                    high = btc_candle_data[&#39;high&#39;],\n                                    low = btc_candle_data[&#39;low&#39;],\n                                    close = btc_candle_data[&#39;close&#39;],\n                                    ),\n                     go.Scatter(x= btc_candle_data.index, y=btc_candle_data[&#39;20 SMA&#39;], line=dict(color=&#39;purple&#39;, width=1))])\n\n\nfig.show() <\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"906\" height=\"583\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/17-10.jpg\" alt=\"\" class=\"wp-image-16218\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/17-10.jpg 906w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/17-10-300x193.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/17-10-768x494.jpg 768w\" sizes=\"(max-width: 906px) 100vw, 906px\" \/><\/figure>\n\n\n\n<p>If you want to obtain the current order book as two arrays (bids\/asks) write the following code:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>base_url = &quot;https:\/\/api.gemini.com\/v1&quot;\nresponse = requests.get(base_url + &quot;\/book\/btcusd&quot;)\nbtc_book = response.json()\nbtc_book<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"897\" height=\"495\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/18-7.jpg\" alt=\"\" class=\"wp-image-16219\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/18-7.jpg 897w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/18-7-300x166.jpg 300w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/18-7-768x424.jpg 768w\" sizes=\"(max-width: 897px) 100vw, 897px\" \/><\/figure>\n\n\n\n<p>It is somewhat messy, isn\u2019t it? Let us clean it up a bit. We will create a data frame for each of the two and then merge them together for a better look.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>df_bid = pd.DataFrame(btc_book[&#39;bids&#39;])\ndf_ask = pd.DataFrame(btc_book[&#39;asks&#39;])\ndf_bid[&#39;timestamp&#39;] = pd.to_datetime(df_ask[&#39;timestamp&#39;], unit=&#39;s&#39;)\ndf_bid.set_index(&#39;timestamp&#39;, inplace=True)\n\ndf_ask[&#39;timestamp&#39;] = pd.to_datetime(df_ask[&#39;timestamp&#39;], unit=&#39;s&#39;)\ndf_ask.set_index(&#39;timestamp&#39;, inplace=True)\n\ndf_bid.head()\ndf_ask.head()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"494\" height=\"725\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/19-2-1.jpg\" alt=\"\" class=\"wp-image-16222\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/19-2-1.jpg 494w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/19-2-1-204x300.jpg 204w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/figure>\n\n\n\n<p>Merge them like this:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>df = pd.merge(df_bid, df_ask, on = &quot;timestamp&quot;, how = &quot;inner&quot;) \ndf = df.rename({&quot;price_x&quot;:&quot;Bid Price&quot;,&quot;amount_x&quot;:&quot;Bid Amount&quot;,\n                &quot;price_y&quot;:&quot;Ask Price&quot;,&quot;amount_y&quot;:&quot;Ask Amount&quot;}, axis=&#39;columns&#39;)\ndf<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"744\" height=\"563\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/20-4.jpg\" alt=\"\" class=\"wp-image-16221\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/20-4.jpg 744w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/20-4-300x227.jpg 300w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><\/figure>\n\n\n\n<p>If you want to obtain the trade history aka the trades that were executed after the specified timestamp you need to have the following in mind.<\/p>\n\n\n\n<p>Firstly, the call without a specified timestamp will return the most recent trades. The timestamps are dates that go back to 1970-01-01 and each request can show up to 500 records.<\/p>\n\n\n\n<p>The request will return a response with:<\/p>\n\n\n\n<p><strong>timestamp <\/strong>\u2013 the time that the trade was executed<\/p>\n\n\n\n<p><strong>timestamps <\/strong>\u2013 the time that the trade was executed in ms<\/p>\n\n\n\n<p><strong>tid <\/strong>\u2013 trade id number<\/p>\n\n\n\n<p><strong>price <\/strong>&#8211; the price the trade was executed at<\/p>\n\n\n\n<p><strong>amount <\/strong>&#8211; &nbsp;&nbsp; The amount that was traded<\/p>\n\n\n\n<p><strong>exchange <\/strong>\u2013 always Gemini<\/p>\n\n\n\n<p><strong>type <\/strong>\u2013 the type of trade (buy, sell, auction, block)<\/p>\n\n\n\n<p><strong>broken <\/strong>\u2013 broken trades aren\u2019t included in a default call<\/p>\n\n\n\n<p>Let us make a request and tidy it up a bit:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>base_url = &quot;https:\/\/api.gemini.com\/v1&quot;\nresponse = requests.get(base_url + &quot;\/trades\/btcusd&quot;)\nbtcusd_trades = pd.DataFrame(response.json(), columns = [&#39;timestamp&#39;,&#39;price&#39;,&#39;amount&#39;,&#39;type&#39;])\nbtcusd_trades[&#39;timestamp&#39;] = pd.to_datetime(btcusd_trades[&#39;timestamp&#39;], unit=&#39;s&#39;)\nbtcusd_trades.set_index(&#39;timestamp&#39;, inplace = True)\nbtcusd_trades.head()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"281\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/21-7.jpg\" alt=\"\" class=\"wp-image-16223\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/21-7.jpg 519w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/21-7-300x162.jpg 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/figure>\n\n\n\n<p>To get the current auction for a symbol we can write this:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>base_url = &quot;https:\/\/api.gemini.com\/v1&quot;\nresponse = requests.get(base_url + &quot;\/auction\/btcusd&quot;)\nbtc_auction = response.json()\nbtc_auction<\/code><\/pre><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>{'next_update_ms': 1610052600000,\n 'next_auction_ms': 1610053200000,\n 'last_auction_eid': 189461049871}\n<\/code><\/pre>\n\n\n\n<p>And for the auction history (have in mind that the public API only returns 7 calendar days of data) do this:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>response = requests.get(base_url + &quot;\/auction\/btcusd\/history&quot;)\nbtc_auction_history = pd.DataFrame(response.json())\nbtc_auction_history.T<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"556\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/23-3.jpg\" alt=\"\" class=\"wp-image-16224\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/23-3.jpg 707w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/23-3-300x236.jpg 300w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p>Gemini\u2019s public API also offers a price feed where we obtain all the prices and 24h percent changes for each coin pair.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>response = requests.get(base_url + &quot;\/pricefeed&quot;)\nprices = pd.DataFrame(response.json())\nprices.set_index(&#39;pair&#39;, inplace = True)\nprint(&#39;There are&#39;,len(prices),&#39;currency pairs\\n&#39;)\nprint(prices.tail())<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"517\" height=\"242\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/24-2.jpg\" alt=\"\" class=\"wp-image-16225\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/24-2.jpg 517w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/24-2-300x140.jpg 300w\" sizes=\"(max-width: 517px) 100vw, 517px\" \/><\/figure>\n\n\n\n<a name=\"how-to-place-orders-with-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to place orders with Gemini<\/strong> API<strong>?<\/strong><\/h2>\n\n\n\n<p>For this part of the article, we will rely on our Gemini API sandbox and show two examples of trading scenarios so you can learn how to place orders with the Gemini API and specify the circumstances of the order execution.<\/p>\n\n\n\n<a name=\"example-one\">\n\n\n\n<p>In the first example, I will show you how to properly and securely launch an order with specified requirements. The thing that we want to do is to launch a trade on ETH when BTC hits a certain price.<\/p>\n\n\n\n<p>Let us go ahead and import the relevant libraries and set up the API Key and Secret for this task:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import requests\nimport hmac\nimport json\nimport base64\nimport hashlib\nimport datetime, time\ngemini_api_key = &quot;YOUR-KEY-HERE&quot;\ngemini_api_secret = &quot;YOUR-KEY-HERE&quot;.encode()<\/code><\/pre><\/div>\n\n\n\n<p>The Gemini API has a \u201cnonce\u201d feature which is a number that must not be repeated and must be increased between order requests. This feature prevents potential hackers who have captured our previous request to simply replay that request. So let us set up a nonce.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>t = datetime.datetime.now()\npayload_nonce =  str(int(time.mktime(t.timetuple())*1000))<\/code><\/pre><\/div>\n\n\n\n<p>We will buy 5 ETH for their current market price if the price of BTC reaches $37900.00. Now, we shall specify the order payload that will carry the main order requirements. As Gemini doesn\u2019t support direct market orders, we will need to go around it in our task loop later on.<\/p>\n\n\n\n<p>This means that the next 3 steps can be skipped for now. I\u2019ve pulled them out of our main loop out of didactic reasons so you can better understand what is happening.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>payload = {\n   &quot;request&quot;: &quot;\/v1\/order\/new&quot;,\n    &quot;nonce&quot;: payload_nonce,\n    &quot;symbol&quot;: &quot;ethusd&quot;,\n    &quot;amount&quot;: &quot;5&quot;,\n    &quot;price&quot;: eth_price,\n    &quot;side&quot;: &quot;buy&quot;,\n    &quot;type&quot;: &quot;exchange limit&quot;,\n}<\/code><\/pre><\/div>\n\n\n\n<p>Moreover, the way that we will go around the direct market order is to launch an exchange limit order with the current limit of the specified symbol.<\/p>\n\n\n\n<p>Gemini advises its users to go around this by using the \u201cimmediate-or-cancel\u201d execution option, coupled with a really aggressive limit price (very high for buy orders and very low for sell orders).<\/p>\n\n\n\n<p>In the next step we will encode our payload and set up the signature.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>encoded_payload = json.dumps(payload).encode()\nb64 = base64.b64encode(encoded_payload)\nsignature = hmac.new(gemini_api_secret, b64, hashlib.sha384).hexdigest()<\/code><\/pre><\/div>\n\n\n\n<p>The next step is to set up the headers for our order:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>request_headers = { &#39;Content-Type&#39;: &quot;text\/plain&quot;,\n                    &#39;Content-Length&#39;: &quot;0&quot;,\n                    &#39;X-GEMINI-APIKEY&#39;: gemini_api_key,\n                    &#39;X-GEMINI-PAYLOAD&#39;: b64,\n                    &#39;X-GEMINI-SIGNATURE&#39;: signature,\n                    &#39;Cache-Control&#39;: &quot;no-cache&quot; }<\/code><\/pre><\/div>\n\n\n\n<p>Now, let us add it all together and look for the specified BTC price in dollars. If the price is reached, the order will launch. If the price is not reached the loop will continue.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import requests\nimport hmac\nimport json\nimport base64\nimport hashlib\nimport pandas as pd\nimport datetime, time\nfrom time import sleep\n\nbase_url = &quot;https:\/\/api.sandbox.gemini.com&quot;\nendpoint = &quot;\/v1\/order\/new&quot;\nurl = base_url + endpoint\n\ngemini_api_key = &quot;master-2rJeGEcrQbx6OKXvSvLR&quot;\ngemini_api_secret = &quot;CZTk6cmFZgVPSnoHij22LZNFZ3S&quot;.encode()\n\ndef Auth(payload):\n    \n    encoded_payload = json.dumps(payload).encode()\n    b64 = base64.b64encode(encoded_payload)\n    signature = hmac.new(gemini_api_secret, b64, hashlib.sha384).hexdigest()\n\n    request_headers = { &#39;Content-Type&#39;: &quot;text\/plain&quot;,\n                &#39;Content-Length&#39;: &quot;0&quot;,\n                &#39;X-GEMINI-APIKEY&#39;: gemini_api_key,\n                &#39;X-GEMINI-PAYLOAD&#39;: b64,\n                &#39;X-GEMINI-SIGNATURE&#39;: signature,\n                &#39;Cache-Control&#39;: &quot;no-cache&quot; }\n    return(request_headers)\n\nwhile True:\n    try:\n        response = requests.get(&quot;https:\/\/api.gemini.com\/v1\/pubticker\/BTCUSD&quot;).json()\n        btc_price = float(response[&#39;ask&#39;])\n        print(btc_price)\n    except exception as e:\n        print(f&#39;Error obtaining data: {e}&#39;)\n        \n    if btc_price &gt;= 50000:\n        try:\n            response = requests.get(&quot;https:\/\/api.gemini.com\/v1\/pubticker\/ETHUSD&quot;).json()\n            eth_price = float(response[&#39;ask&#39;])\n            print(eth_price)\n        except Exception as e:\n            print(f&#39;Error obtaining data: {e}&#39;)\n            \n        t = datetime.datetime.now()\n        payload_nonce =  str(int(time.mktime(t.timetuple())*1000))  \n        \n        payload = {\n            &quot;request&quot;: &quot;\/v1\/order\/new&quot;,\n            &quot;nonce&quot;: payload_nonce,\n            &quot;symbol&quot;: &quot;ethusd&quot;,\n            &quot;amount&quot;: &quot;1&quot;,\n            &quot;price&quot;: eth_price,\n            &quot;side&quot;: &quot;buy&quot;,\n            &quot;type&quot;: &quot;exchange limit&quot;,\n            &quot;account&quot;: &quot;algotrading&quot;\n            }\n        \n        \n        try:\n            new_order = requests.post(url,\n                            data=None,\n                            headers=Auth(payload)).json()\n            print(new_order)\n            \n        except Exception as e:\n            print(f&#39;Error placing order: {e}&#39;)\n            \n        print(new_order)\n\n        check_status = new_order[&#39;order_id&#39;]\n\n        sleep(2)\n\n        t = datetime.datetime.now()\n        payload_nonce =  str(int(time.mktime(t.timetuple())*1000))\n\n        payload1 = {\n            &quot;request&quot; : &#39;\/v1\/order\/status&#39;,\n            &quot;nonce&quot; : payload_nonce,\n            &quot;order_id&quot; : check_status,\n            &quot;account&quot; : &quot;algotrading&quot;, \n        }\n        \n        try:  \n            check = requests.post(base_url + &#39;\/v1\/order\/status&#39;,\n                            data=None,\n                            headers=Auth(payload1)).json()\n            \n        except Exception as e:\n            print(f&#39;Error checking order: {e}&#39;)\n\n        if str(check[&#39;is_live&#39;]) == &#39;True&#39;:\n            print (&#39;Order placed at {}&#39;.format(pd.Timestamp.now()))\n            break\n\n        else:\n            print(&#39;Order was canceled {}&#39;.format(pd.Timestamp.now()))\n            break\n\n    else:\n        print(&#39;BTC did not reach the specified price&#39;)\n        sleep(10)\n        continue<\/code><\/pre><\/div>\n\n\n\n<a name=\"example-two\">\n\n\n\n<p>The next example will use a similar order logic, but it will look for the percentage change between two symbols. The main task will be to execute an ETH trade when BTC moves 5% in the last 5 minutes.<\/p>\n\n\n\n<p>This means that we will want to create a loop that will obtain the prices of the two cryptos and calculate the percentage change between the two.<\/p>\n\n\n\n<p>If the percentage change is less than 5%, the program will be sleeping for 5 minutes and calculating the percentage change again. If the percentage change is equal to or more than 5% the trade will execute.<\/p>\n\n\n\n<p>The code will be coupled with error handlings for each major step. The code up to the main loop remains the same as in our previous example.<\/p>\n\n\n\n<p>Here is the main loop:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>while True:\n    try:\n        response = requests.get(&quot;https:\/\/api.gemini.com\/v1\/pubticker\/BTCUSD&quot;).json()\n        btc_old = float(response[&#39;ask&#39;])\n        print(btc_old)\n    except exception as e:\n        print(f&#39;Error obtaining data: {e}&#39;)\n    \n    sleep(300)\n    \n    try:\n        response = requests.get(&quot;https:\/\/api.gemini.com\/v1\/pubticker\/BTCUSD&quot;).json()\n        btc_new = float(response[&#39;ask&#39;])\n        print(btc_new)\n    except exception as e:\n        print(f&#39;Error obtaining data: {e}&#39;)\n    \n    percent = ((btc_new - btc_old)*100) \/ btc_old\n        \n    if percent &gt;= 5:\n        try:\n            response = requests.get(&quot;https:\/\/api.gemini.com\/v1\/pubticker\/ETHUSD&quot;).json()\n            eth_price = float(response[&#39;ask&#39;])\n            print(eth_price)\n        except Exception as e:\n            print(f&#39;Error obtaining data: {e}&#39;)\n            \n        t = datetime.datetime.now()\n        payload_nonce =  str(int(time.mktime(t.timetuple())*1000))  \n        \n        payload = {\n            &quot;request&quot;: &quot;\/v1\/order\/new&quot;,\n            &quot;nonce&quot;: payload_nonce,\n            &quot;symbol&quot;: &quot;ethusd&quot;,\n            &quot;amount&quot;: &quot;1&quot;,\n            &quot;price&quot;: eth_price,\n            &quot;side&quot;: &quot;buy&quot;,\n            &quot;type&quot;: &quot;exchange limit&quot;,\n            &quot;account&quot;: &quot;algotrading&quot;\n            }\n        \n        \n        try:\n            new_order = requests.post(url,\n                            data=None,\n                            headers=Auth(payload)).json()\n            print(new_order)\n            \n        except Exception as e:\n            print(f&#39;Error placing order: {e}&#39;)\n            \n        print(new_order)\n\n        check_status = new_order[&#39;order_id&#39;]\n\n        sleep(2)\n\n        t = datetime.datetime.now()\n        payload_nonce =  str(int(time.mktime(t.timetuple())*1000))\n\n        payload1 = {\n            &quot;request&quot; : &#39;\/v1\/order\/status&#39;,\n            &quot;nonce&quot; : payload_nonce,\n            &quot;order_id&quot; : check_status,\n            &quot;account&quot; : &quot;algotrading&quot;, \n        }\n        \n        try:  \n            check = requests.post(base_url + &#39;\/v1\/order\/status&#39;,\n                            data=None,\n                            headers=Auth(payload1)).json()\n            \n        except Exception as e:\n            print(f&#39;Error checking order: {e}&#39;)\n\n        if str(check[&#39;is_live&#39;]) == &#39;True&#39;:\n            print (&#39;Order placed at {}&#39;.format(pd.Timestamp.now()))\n            break\n\n        else:\n            print(&#39;Order was canceled {}&#39;.format(pd.Timestamp.now()))\n            break\n\n    else:\n        print(f&#39;BTC did not reach the requirement. Percentage move is at {percent}&#39;)\n        continue<\/code><\/pre><\/div>\n\n\n\n<a name=\"how-to-cancel-orders-with-gemini\">\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How to cancel orders with Gemini API?<\/strong><\/h3>\n\n\n\n<p>Orders can be canceled with Gemini by passing the order nonce and id into your response.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;nonce&quot;: &lt;nonce&gt;,\n    &quot;order_id&quot;: &lt;order-id-here&gt;,\n    &quot;request&quot;: &quot;\/v1\/order\/cancel&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<p>To cancel all session orders write the following:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;request&quot;: &quot;\/v1\/order\/cancel\/session&quot;,\n    &quot;nonce&quot;: &lt;nonce&gt;\n}<\/code><\/pre><\/div>\n\n\n\n<p>To cancel all active orders write this:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;nonce&quot;: &lt;nonce&gt;,\n    &quot;request&quot;: &quot;\/v1\/order\/cancel\/all&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<a name=\"what-order-execution-options-does-gemini-have\">\n\n\n\n<h3 class=\"wp-block-heading\"><strong>What order execution options does Gemini have?<\/strong><\/h3>\n\n\n\n<p>Gemini features several order execution options that can be added to your main order payload as \u201ctype\u201d : \u201coption name\u201d. Let us see what they do:<\/p>\n\n\n\n<p>&#8220;maker-or-cancel\u201d \u2013 This order only adds liquidity to the order book. If any part of the order wasn\u2019t filled immediately, the whole order will be canceled before the execution.<\/p>\n\n\n\n<p>&#8220;immediate-or-cancel&#8221; \u2013 This order only removes liquidity from the order book. This means that it will fill whatever part of the order it can immediately and cancel the remaining amount so that it doesn\u2019t get added to another order book.<\/p>\n\n\n\n<p>&#8220;fill-or-kill&#8221; \u2013 This order, like the previous one, removes liquidity from the order book. It will fill the entire order immediately or cancel.<\/p>\n\n\n\n<p>&#8220;auction-only&#8221; \u2013 This order will be added to the auction-only book for the next auction for a specified symbol.<\/p>\n\n\n\n<p>&#8220;indication-of-interest&#8221; \u2013 is a request for liquidity from block trading market-makers for a specified symbol.<\/p>\n\n\n\n<a name=\"how-to-get-notional-and-trade-volumes-with-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to get Notional and Trade Volumes with Gemini API?<\/strong><\/h2>\n\n\n\n<p>In order to get these volumes we will need to do several things when calling the API that were shown in the previous trading examples. So let us code the notional volumes request:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import requests\nimport hmac\nimport json\nimport base64\nimport hashlib\nimport pandas as pd\nimport datetime, time\nfrom time import sleep\n\ngemini_api_key = &quot;master-2rJeGEcrQbx6OKXvSvLR&quot;\ngemini_api_secret = &quot;CZTk6cmFZgVPSnoHij22LZNFZ3S&quot;.encode()\n\nt = datetime.datetime.now()\npayload_nonce =  str(int(time.mktime(t.timetuple())*1000))\n\nbase_url = &quot;https:\/\/api.gemini.com&quot;\nendpoint = &quot;\/v1\/notionalvolume&quot;\nurl = base_url + endpoint\n\npayload = {\n            &quot;request&quot;: &quot;\/v1\/notionalvolume&quot;,\n            &quot;nonce&quot;: payload_nonce,\n            }\n\nencoded_payload = json.dumps(payload).encode()\nb64 = base64.b64encode(encoded_payload)\nsignature = hmac.new(gemini_api_secret, b64, hashlib.sha384).hexdigest()\n        \nrequest_headers = { &#39;Content-Type&#39;: &quot;text\/plain&quot;,\n                    &#39;Content-Length&#39;: &quot;0&quot;,\n                    &#39;X-GEMINI-APIKEY&#39;: gemini_api_key,\n                    &#39;X-GEMINI-PAYLOAD&#39;: b64,\n                    &#39;X-GEMINI-SIGNATURE&#39;: signature,\n                    &#39;Cache-Control&#39;: &quot;no-cache&quot; }\n\nresponse = requests.post(url,\n                        data=None,\n                        headers=request_headers)\nprint(response)<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"420\" height=\"503\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/25-2.jpg\" alt=\"\" class=\"wp-image-16226\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/25-2.jpg 420w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/25-2-250x300.jpg 250w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/figure>\n\n\n\n<p>In order to get the trade volumes change the payload and required endpoints like this:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;nonce&quot;: &lt;nonce&gt;,\n    &quot;request&quot;: &quot;\/v1\/tradevolume&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"436\" height=\"805\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/26-2.jpg\" alt=\"\" class=\"wp-image-16227\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/26-2.jpg 436w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/26-2-162x300.jpg 162w\" sizes=\"(max-width: 436px) 100vw, 436px\" \/><\/figure>\n\n\n\n<a name=\"how-to-use-gemini-clearing-orders\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to use Gemini Clearing orders?<\/strong><\/h2>\n\n\n\n<p>The Gemini clearing endpoint allows two parties to conduct a trade-off in the order book. The initiator enters the trade details for a specified symbol and creates a trade_id.<\/p>\n\n\n\n<p>If a counterparty_id is supplied, only the counterparty can confirm the order. It the id is not supplied, the ticket will generate a trade_id that can be filled by any counterparty.<\/p>\n\n\n\n<p>Here is how a clearing order would look like:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import json\nimport hmac\nimport base64\nimport requests\nimport hashlib\nimport datetime, time\n\nbase_url = &quot;https:\/\/api.gemini.com&quot;\nendpoint = &quot;\/v1\/clearing\/new&quot;\nurl = base_url + endpoint\n\ngemini_api_key = &quot;YOUR-API-KEY-HERE&quot;\ngemini_api_secret = &quot;YOUR-SECRET-KEY-HERE&quot;.encode()\ncounterparty_id = &quot;COUNTERPARTY-ID-HERE&quot;\nt = datetime.datetime.now()\npayload_nonce =  str(int(time.mktime(t.timetuple())))\n\npayload = {\n    &quot;request&quot;: endpoint,\n    &quot;nonce&quot;: payload_nonce,\n    &quot;counterparty_id&quot;: counterparty_id,\n    &quot;expires_in_hrs&quot;: 24,\n    &quot;symbol&quot;: &quot;ethusd&quot;,\n    &quot;amount&quot;: &quot;20&quot;,\n    &quot;price&quot;: &quot;9000.00&quot;,\n    &quot;side&quot;: &quot;buy&quot;\n}\n\nencoded_payload = json.dumps(payload).encode()\nb64 = base64.b64encode(encoded_payload)\nsignature = hmac.new(gemini_api_secret, b64, hashlib.sha384).hexdigest()\n\nrequest_headers = { &#39;Content-Type&#39;: &quot;text\/plain&quot;,\n                    &#39;Content-Length&#39;: &quot;0&quot;,\n                    &#39;X-GEMINI-APIKEY&#39;: gemini_api_key,\n                    &#39;X-GEMINI-PAYLOAD&#39;: b64,\n                    &#39;X-GEMINI-SIGNATURE&#39;: signature,\n                    &#39;Cache-Control&#39;: &quot;no-cache&quot; }\n\nresponse = requests.post(url,\n                        data=None,\n                        headers=request_headers)\n\nnew_clearing_order = response.json()\nprint(new_clearing_order)<\/code><\/pre><\/div>\n\n\n\n<a name=\"how-to-use-fund-management-apis-from-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to use Fund Management APIs from Gemini?<\/strong><\/h2>\n\n\n\n<p>There are several fund management endpoints and we will mention a few of them. For a full list check the Gemini API documentation that is found on the following link:<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.gemini.com\/rest-api\/#get-available-balances\">https:\/\/docs.gemini.com\/rest-api\/#get-available-balances<\/a><\/p>\n\n\n\n<p>If you want to add banking information to be sent via API there is the Add Bank endpoint. Have in mind for the bank to be verified, a trader must send in a wire for any amount from the bank account.<\/p>\n\n\n\n<p>Following our last examples on how to properly use and call the endpoints, we need to change the payload like the following:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n  &quot;request&quot;: &quot;v1\/payments\/addbank&quot;,\n  &quot;nonce&quot;: &lt;nonce&gt;,\n  &quot;accountnumber&quot;: &quot;account-number-string&quot;,\n  &quot;routing&quot;: &quot;routing-number-string&quot;,\n  &quot;type&quot;: &quot;checking&quot;,\n  &quot;name&quot;: &quot;Igor Radovanovic Checking&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<p>To withdraw your crypto funds change the payload to this:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>{\n   &quot;request&quot;:&quot;\/v1\/withdraw\/btc&quot;,\n   &quot;nonce&quot;: &lt;nonce&gt;,\n   &quot;address&quot;:&quot;mi98Z9brJ3TgaKsmvXatuRahbFRUFKRUdR&quot;,\n   &quot;amount&quot;:&quot;1&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<p>I\u2019d advise readers to explore these endpoints on their own as they are quite straightforward and for those that have decided to use the Gemini API.<\/p>\n\n\n\n<a name=\"what-is-the-heartbead-function-from-gemini\">\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is the Heartbeat function from Gemini API?<\/strong><\/h2>\n\n\n\n<p>Heartbeat is a part of Gemini\u2019s Session APIs that prevents a session from timing out and canceling orders if the required heartbeat flag has bet properly set.<\/p>\n\n\n\n<p>This may only be required if there aren\u2019t any other private API requests that have been made. Any message that arrives will reset the heartbeat timer.<\/p>\n\n\n\n<p>To set up the heartbeat, change the payload to:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;nonce&quot;: &lt;nonce&gt;,\n    &quot;request&quot;: &quot;\/v1\/heartbeat&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<a name=\"about-gemini-exchange\">\n\n\n\n<h2 class=\"wp-block-heading\">More about Gemini<\/h2>\n\n\n\n<p>Moreover, the creators of Gemini were also the ones that created ConnectU, a predecessor to Facebook.<\/p>\n\n\n\n<p>When it comes to cryptocurrency Gemini offers its users access to over 20 cryptos like Bitcoin, Ethereum, Litecoin, XRP, Stellar, Tezos, Cardano, Polkadot, and more.<\/p>\n\n\n\n<p>Examples of some features that the Active Trader brings are the following: advanced charting, auctions, block trading, and multiple order types.<\/p>\n\n\n\n<p>This is also integrated with their mobile app that comes with custom push notifications and a possibility of trading with it. Moreover, you can pay retailers directly with your crypto.<\/p>\n\n\n\n<p>All you need to do is to push the \u201cPay\u201d button that is located near the bottom of the app interface. Select the crypto you want to pay in and the retailer. After that, a custom QR code will appear that can be scanned for payment.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"516\" data-id=\"16228\"  src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/Capture-4.jpg\" alt=\"\" class=\"wp-image-16228\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/Capture-4.jpg 352w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/Capture-4-205x300.jpg 205w\" sizes=\"(max-width: 352px) 100vw, 352px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"508\" data-id=\"16229\"  src=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/2-13.jpg\" alt=\"\" class=\"wp-image-16229\" srcset=\"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/2-13.jpg 356w, https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2022\/07\/2-13-210x300.jpg 210w\" sizes=\"(max-width: 356px) 100vw, 356px\" \/><\/figure>\n<figcaption class=\"blocks-gallery-caption\">Source: https:\/\/www.gemini.com\/mobile-app<\/figcaption><\/figure>\n\n\n\n<p>For algorithmic traders, Gemini features a good API that is easy to use and integrate and we will explore its features later down the article.<\/p>\n\n\n\n<p>When it comes to funding your account on Gemini, you\u2019ll need to do it through your bank account. This means that it can\u2019t be funded by the use of a credit or debit card.<\/p>\n\n\n\n<p>You also have the option to fund your Gemini wallet with another crypto wallet but the currencies must be along the lines of BTC, LTC, BCH, ETH or ZEC.<\/p>\n\n\n\n<p>Your maximum funding price ranges from $500 to $15k on a monthly basis, while the withdrawal amount is set to $100k.<\/p>\n\n\n\n<p>Your money is stored in the Gemini Wallet that is a hot wallet aka an \u201cinstitutional-grade cold storage system\u201d. This means that it should be safe from hacking.<\/p>\n\n\n\n<p>If a hack happens the funds are FDIC insured which means that they should remain safe. Compared to other similar platforms, Gemini might be the safest one for storing money.<\/p>\n\n\n\n<p>Gemini has a Gemini Clearing function that allows two parties to settle a trade off the order book. Here Gemini is a regulating third-party in the pre-arranged transactions.<\/p>\n\n\n\n<p>Gemini offers its users educational resources so they can learn more about the world of cryptocurrency and trading before sailing the boat.<\/p>\n\n\n\n<p>They have their Cryptopedia that feature more than 160 articles covering 4 main categories which are cryptocurrencies, security, trading and investing, and DeFi.<\/p>\n\n\n\n<p>Gemini also features 3 distinct webinars that allow beginners to make a solid grasp of trading and finance:<\/p>\n\n\n\n<ul><li><strong>Intro to Crypto Webinar<\/strong> \u2013 here you are taught about the basics of the cryptocurrency ecosystem.<\/li><li><strong>Intro to Ethereum Webinar<\/strong> \u2013 this one is self-explanatory.<\/li><li><strong>Crypto 201 Webinar<\/strong> \u2013 here you will learn about the main differences between the ETH and BTC blockchains, ERC-20 tokens, and more.<\/li><\/ul>\n\n\n\n<a name=\"full-code\">\n\n\n\n<h2 class=\"wp-block-heading\">Full code:<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/IgorWounds\/Gemini-API-Algotrading101\">GitHub Link<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_8755\" class=\"pvc_stats total_only  \" data-element-id=\"8755\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/algotrading101.com\/learn\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>Table of contents: What is Gemini API? What is Gemini? What is the Gemini Dollar? Is Gemini free? Why should I use Gemini? Why shouldn\u2019t I use the Gemini? Is Gemini available in my country? What are the alternatives to using Gemini API? What clients are available for the Gemini API? How to get started [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":8764,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_lmt_disableupdate":"no","_lmt_disable":"no","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[3,2],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Gemini API - A Step-by-Step Guide - AlgoTrading101 Blog<\/title>\n<meta name=\"description\" content=\"Gemini API is a method that allows us to automatically trade cryptocurrencies on Gemini via code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Gemini API - A Step-by-Step Guide - AlgoTrading101 Blog\" \/>\n<meta property=\"og:description\" content=\"Gemini API is a method that allows us to automatically trade cryptocurrencies on Gemini via code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"Quantitative Trading Ideas and Guides - AlgoTrading101 Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-06T18:05:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-03T21:10:33+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2021\/04\/Gemini-API-Guide.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Igor Radovanovic\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Igor Radovanovic\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"23 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Gemini API - A Step-by-Step Guide - AlgoTrading101 Blog","description":"Gemini API is a method that allows us to automatically trade cryptocurrencies on Gemini via code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/","og_locale":"en_US","og_type":"article","og_title":"Gemini API - A Step-by-Step Guide - AlgoTrading101 Blog","og_description":"Gemini API is a method that allows us to automatically trade cryptocurrencies on Gemini via code.","og_url":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/","og_site_name":"Quantitative Trading Ideas and Guides - AlgoTrading101 Blog","article_published_time":"2021-04-06T18:05:29+00:00","article_modified_time":"2023-04-03T21:10:33+00:00","og_image":[{"width":1280,"height":720,"url":"http:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2021\/04\/Gemini-API-Guide.png","type":"image\/png"}],"author":"Igor Radovanovic","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Igor Radovanovic","Est. reading time":"23 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/#article","isPartOf":{"@id":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/"},"author":{"name":"Igor Radovanovic","@id":"https:\/\/algotrading101.com\/learn\/#\/schema\/person\/a7ae60c112a73b7c3fe14ac56726a0ae"},"headline":"Gemini API &#8211; A Step-by-Step Guide","datePublished":"2021-04-06T18:05:29+00:00","dateModified":"2023-04-03T21:10:33+00:00","mainEntityOfPage":{"@id":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/"},"wordCount":3200,"publisher":{"@id":"https:\/\/algotrading101.com\/learn\/#organization"},"articleSection":["Programming","Trading"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/","url":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/","name":"Gemini API - A Step-by-Step Guide - AlgoTrading101 Blog","isPartOf":{"@id":"https:\/\/algotrading101.com\/learn\/#website"},"datePublished":"2021-04-06T18:05:29+00:00","dateModified":"2023-04-03T21:10:33+00:00","description":"Gemini API is a method that allows us to automatically trade cryptocurrencies on Gemini via code.","breadcrumb":{"@id":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/algotrading101.com\/learn\/gemini-api-guide\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/algotrading101.com\/learn\/gemini-api-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/algotrading101.com\/learn\/"},{"@type":"ListItem","position":2,"name":"Gemini API &#8211; A Step-by-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/algotrading101.com\/learn\/#website","url":"https:\/\/algotrading101.com\/learn\/","name":"Quantitative Trading Ideas and Guides - AlgoTrading101 Blog","description":"Authentic Stories about Algorithmic trading, coding and life.","publisher":{"@id":"https:\/\/algotrading101.com\/learn\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/algotrading101.com\/learn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/algotrading101.com\/learn\/#organization","name":"AlgoTrading101","url":"https:\/\/algotrading101.com\/learn\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/algotrading101.com\/learn\/#\/schema\/logo\/image\/","url":"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2020\/11\/AlgoTrading101-Lucas-Liew.jpg","contentUrl":"https:\/\/algotrading101.com\/learn\/wp-content\/uploads\/2020\/11\/AlgoTrading101-Lucas-Liew.jpg","width":1200,"height":627,"caption":"AlgoTrading101"},"image":{"@id":"https:\/\/algotrading101.com\/learn\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/algotrading101.com\/learn\/#\/schema\/person\/a7ae60c112a73b7c3fe14ac56726a0ae","name":"Igor Radovanovic","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/algotrading101.com\/learn\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d46175c509b3ee240a1e2bbe735a4d1e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d46175c509b3ee240a1e2bbe735a4d1e?s=96&d=mm&r=g","caption":"Igor Radovanovic"},"sameAs":["https:\/\/igorradovanovic.com","https:\/\/www.linkedin.com\/in\/igor-radovanovic-profile"],"url":"https:\/\/algotrading101.com\/learn\/author\/igor\/"}]}},"modified_by":"Igor Radovanovic","_links":{"self":[{"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/posts\/8755"}],"collection":[{"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/comments?post=8755"}],"version-history":[{"count":12,"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/posts\/8755\/revisions"}],"predecessor-version":[{"id":21158,"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/posts\/8755\/revisions\/21158"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/media\/8764"}],"wp:attachment":[{"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/media?parent=8755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/categories?post=8755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/algotrading101.com\/learn\/wp-json\/wp\/v2\/tags?post=8755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}