{"id":94,"date":"2025-04-23T19:57:47","date_gmt":"2025-04-23T17:57:47","guid":{"rendered":"https:\/\/quantifier.fr\/?p=94"},"modified":"2025-05-02T11:14:39","modified_gmt":"2025-05-02T09:14:39","slug":"appeler-lapi-alphavantage","status":"publish","type":"post","link":"https:\/\/quantifier.fr\/index.php\/2025\/04\/23\/appeler-lapi-alphavantage\/","title":{"rendered":"Appeler l&#8217;API Alphavantage"},"content":{"rendered":"\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"http:\/\/quantifier.fr\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-23-2025-07_42_17-PM.png\" alt=\"\" class=\"wp-image-90\" style=\"width:402px;height:auto\" srcset=\"https:\/\/quantifier.fr\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-23-2025-07_42_17-PM.png 1024w, https:\/\/quantifier.fr\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-23-2025-07_42_17-PM-300x300.png 300w, https:\/\/quantifier.fr\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-23-2025-07_42_17-PM-150x150.png 150w, https:\/\/quantifier.fr\/wp-content\/uploads\/2025\/04\/ChatGPT-Image-Apr-23-2025-07_42_17-PM-768x768.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Vous pouvez g\u00e9n\u00e9rer une cl\u00e9 d&#8217;acc\u00e8s gratuite \u00e0 l&#8217;API Alphavantage. Avec la cl\u00e9 gratuite vous serez limit\u00e9 \u00e0 25 requ\u00eates par jour. Au del\u00e0, il vous faudra g\u00e9n\u00e9rer une cl\u00e9 payante. <\/p>\n\n\n\n<p>Personnellement, je me suis servi d&#8217;Alphavantage payant pour t\u00e9l\u00e9charger des  cotations US intra journali\u00e8res. Ci-dessous le code javascript : <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n\/\/ Remplacer par la cl\u00e9 g\u00e9n\u00e9r\u00e9e sur Alpha Vantage\nconst API_KEY = &quot;votre cl\u00e9&quot;;\n\nconst interval = &quot;1min&quot;; \/\/ Interval de temps\nconst outputSize = &quot;full&quot;; \/\/ &quot;compact&quot; (100 points) ou &quot;full&quot; (historique complet)\n\nfunction wait(ms) {\n    return new Promise(resolve =&gt; setTimeout(resolve, ms));\n}\n\nasync function fetchStockData(ticker, month) {\n    url = `https:\/\/www.alphavantage.co\/query?function=TIME_SERIES_INTRADAY&amp;symbol=${ticker}&amp;interval=${interval}&amp;month=${month}&amp;apikey=${API_KEY}&amp;outputsize=${outputSize}`;\n\n    try {\n        const response = await fetch(url);\n        const data = await response.json();\n\n        if (!data&#x5B;&quot;Time Series (1min)&quot;]) {\n            console.error(`\u26a0\ufe0f Erreur : Pas de donn\u00e9es pour ${ticker} ${url}`);\n            return;\n        }\n\n        Object.entries(data&#x5B;&quot;Time Series (1min)&quot;])\n            .forEach((&#x5B;timestamp, values]) =&gt; {\n              const dateObj = new Date(timestamp);\n              \/\/ Format: AAAA\/MM\/JJ\n              const date = dateObj.toLocaleDateString('en-ZA'); \n              \/\/ Format: HH:MM              \n              const time = dateObj.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' }); \n              console.log(`${ticker};${date};${time};${values&#x5B;&quot;1. open&quot;]};${values&#x5B;&quot;4. close&quot;]};${values&#x5B;&quot;2. high&quot;]};${values&#x5B;&quot;3. low&quot;]};${values&#x5B;&quot;5. volume&quot;]}`);\n            });\n\n    } catch (error) {\n        console.error(`\u274c Erreur lors de la r\u00e9cup\u00e9ration de ${ticker} :`, error.message);\n    }\n}\n\nsetTimeout(()=&gt;{fetchStockData('AAPL', '2024-12');},0);\n\n\/\/indiquez votre ticker et le mois souhait\u00e9 pour les donn\u00e9es intra journali\u00e8res\nsetTimeout(()=&gt;{fetchStockData('votre ticker', 'AAAA-MM');},0);\n\n<\/pre><\/div>\n\n\n<p>et l&#8217;appel dans le terminal node.js<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-accent-6-background-color has-background\">node alphavantage.js &gt;&gt; c:\\temp\\intraday.csv<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vous pouvez g\u00e9n\u00e9rer une cl\u00e9 d&#8217;acc\u00e8s gratuite \u00e0 l&#8217;API Alphavantage. Avec la cl\u00e9 gratuite vous serez limit\u00e9 \u00e0 25 requ\u00eates par jour. Au del\u00e0, il vous faudra g\u00e9n\u00e9rer une cl\u00e9 payante. Personnellement, je me suis servi d&#8217;Alphavantage payant pour t\u00e9l\u00e9charger des cotations US intra journali\u00e8res. Ci-dessous le code javascript : et l&#8217;appel dans le terminal [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-94","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/comments?post=94"}],"version-history":[{"count":9,"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":112,"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/posts\/94\/revisions\/112"}],"wp:attachment":[{"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/media?parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/categories?post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/quantifier.fr\/index.php\/wp-json\/wp\/v2\/tags?post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}