{"id":15406774,"url":"https://github.com/dannyben/nasdaq","last_synced_at":"2025-04-18T02:57:52.299Z","repository":{"id":56889858,"uuid":"59224587","full_name":"DannyBen/nasdaq","owner":"DannyBen","description":"Nasdaq Data Link API Ruby Library and Command Line","archived":false,"fork":false,"pushed_at":"2024-04-25T03:28:12.000Z","size":902,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T20:56:26.419Z","etag":null,"topics":["api","api-client","command-line","economic-data","gem","quandl","quandl-api","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DannyBen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/demo/.gitignore","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-19T16:39:59.000Z","updated_at":"2024-09-21T19:48:30.000Z","dependencies_parsed_at":"2024-02-23T14:27:17.318Z","dependency_job_id":"c40800c9-7c67-4ea9-b263-fdae3fd143e0","html_url":"https://github.com/DannyBen/nasdaq","commit_stats":null,"previous_names":["dannyben/quata"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fnasdaq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fnasdaq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fnasdaq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fnasdaq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyBen","download_url":"https://codeload.github.com/DannyBen/nasdaq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249417131,"owners_count":21268201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","command-line","economic-data","gem","quandl","quandl-api","ruby"],"created_at":"2024-10-01T16:25:19.685Z","updated_at":"2025-04-18T02:57:52.274Z","avatar_url":"https://github.com/DannyBen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nasdaq Data Link API and Command Line\n\n[![Gem Version](https://badge.fury.io/rb/nasdaq.svg)](https://badge.fury.io/rb/nasdaq)\n[![Build Status](https://github.com/DannyBen/nasdaq/workflows/Test/badge.svg)](https://github.com/DannyBen/nasdaq/actions?query=workflow%3ATest)\n[![Maintainability](https://api.codeclimate.com/v1/badges/1d68eed3be3481f48066/maintainability)](https://codeclimate.com/github/DannyBen/nasdaq/maintainability)\n\n---\n\nLightweight ruby library and command line interface for accessing the \n[Nasdaq Data Link API][1] (formerly Quandl) with direct access to all of its\nendpoints.\n\n**This gem is not affiliated with Nasdaq or with Quandl.**\n\n---\n\n## Install\n\n```\n$ gem install nasdaq\n```\n\nOr with bundler:\n\n```ruby\ngem 'nasdaq'\n```\n\n\n## Features\n\n* Easy to use interface.\n* Use as a library or through the command line.\n* Access any of the API endpoints directly.\n* Display output in various formats.\n* Save output to a file.\n* Includes a built in file cache (disabled by default).\n\n\n## Usage\n\nFirst, require and initialize with your-api-key\n\n```ruby\nrequire 'nasdaq'\nnasdaq = Nasdaq::API.new 'your-api-key'\n```\n\nNow, you can access any API endpoint with any optional parameter, like\nthis:\n\n```ruby\nresult = nasdaq.get \"datasets/WIKI/AAPL\", rows: 3 # =\u003e Hash\n```\n\nIn addition, for convenience, you can use the first part of the endpoint as\na method name, like this:\n\n```ruby\nresult = nasdaq.datasets \"WIKI/AAPL\", rows: 3\n```\n\nIn other words, these calls are the same:\n\n```ruby\nnasdaq.get 'endpoint', param: value\nnasdaq.endpoint, param: value\n```\n\nas well as these two:\n\n```ruby\nnasdaq.get 'endpoint/sub', param: value\nnasdaq.endpoint 'sub', param: value\n```\n\nBy default, you will get a ruby hash in return. If you wish to have more \ncontrol over the response, use the `get!` method instead:\n\n```ruby\nresult = nasdaq.get! \"datasets/WIKI/AAPL\", rows: 3\n\n# Request Object\np result.request.class\n# =\u003e HTTParty::Request\n\n# Response Object\np result.response.class\n# =\u003e Net::HTTPOK\n\np result.response.body\n# =\u003e JSON string\n\np result.response.code\n# =\u003e 200\n\np result.response.msg\n# =\u003e OK\n\n# Headers Object\np result.headers\n# =\u003e Hash with headers\n\n# Parsed Response Object\np result.parsed_response\n# =\u003e Hash with HTTParty parsed response \n#    (this is the content returned with #get)\n```\n\nYou can get the response as CSV by calling `get_csv`:\n\n```ruby\nresult = nasdaq.get_csv \"datasets/WIKI/AAPL\", rows: 3\n# =\u003e CSV string\n```\n\nTo save the output directly to a file, use the `save` method:\n\n```ruby\nnasdaq.save \"filename.json\", \"datasets/WIKI/AAPL\", rows: 3\n```\n\nOr, to save CSV, use the `save_csv` method:\n\n```ruby\nnasdaq.save_csv \"filename.csv\", \"datasets/WIKI/AAPL\", rows: 3\n```\n\n\n## Command Line\n\nThe command line utility `nasdaq` acts in a similar way. To use your-api-key,\nsimply set it in the environment variables `NASDAQ_KEY`:\n\n```\n$ export NASDAQ_KEY=your_key\n```\n\nThese commands are available:\n\n```bash\n$ nasdaq get PATH [PARAMS...]        # print the output.  \n$ nasdaq pretty PATH [PARAMS...]     # print a pretty JSON.  \n$ nasdaq see PATH [PARAMS...]        # print a colored output.  \n$ nasdaq url PATH [PARAMS...]        # show the constructed URL.  \n$ nasdaq save FILE PATH [PARAMS...]  # save the output to a file.  \n```\n\nRun `nasdaq --help` for more information, or view the [full usage help][2].\n\nExamples:\n\n```bash\n# Shows the first two databases \n$ nasdaq see databases per_page:2\n\n# Or more compactly, as CSV\n$ nasdaq get databases per_page:2\n\n# Prints CSV to screen (CSV is the default in the command line)\n$ nasdaq get datasets/WIKI/AAPL\n\n# Prints JSON instead\n$ nasdaq get datasets/WIKI/AAPL.json\n\n# Pass arguments using the same syntax - key:value\n$ nasdaq get datasets/WIKI/AAPL rows:5\n\n# Pass arguments that require spaces\n$ nasdaq get datasets.json \"query:qqq index\"\n\n# Prints a colored output\n$ nasdaq see datasets/WIKI/AAPL rows:5\n\n# Saves a file\n$ nasdaq save output.csv datasets/WIKI/AAPL rows:5\n\n# Shows the underlying URL for the request, good for debugging\n$ nasdaq url datasets/WIKI/AAPL rows:5\n# =\u003e https://data.nasdaq.com/api/v3/datasets/WIKI/AAPL.csv?api_key=YOUR_KEY\u0026rows=5\n```\n\n## Caching\n\nThe Nasdaq library uses the [Lightly][3] gem for automatic HTTP caching.\nTo take the path of least surprises, caching is disabled by default.\n\nYou can enable and customize it by either passing options on \ninitialization, or by accessing the `Lightly` object directly at \na later stage.\n\n```ruby\nnasdaq = Nasdaq::API.new 'your-api-key', use_cache: true\nnasdaq = Nasdaq::API.new 'your-api-key', use_cache: true, cache_dir: 'tmp'\nnasdaq = Nasdaq::API.new 'your-api-key', use_cache: true, cache_life: 120\n\n# or \n\nnasdaq = Nasdaq::API.new 'your-api-key'\nnasdaq.cache.enable\nnasdaq.cache.dir = 'tmp/cache'   # Change cache folder\nnasdaq.cache.life = 120          # Change cache life to 2 minutes\n```\n\nTo enable caching for the command line, simply set one or both of \nthese environment variables:\n\n```bash\n$ export NASDAQ_CACHE_DIR=cache   # default: 'cache'\n$ export NASDAQ_CACHE_LIFE=120    # default: 3600 (1 hour)\n$ nasdaq get datasets/WIKI/AAPL\n# =\u003e This call will be cached\n```\n\n\n## Command Line Demo\n\n![Demo](https://raw.githubusercontent.com/DannyBen/nasdaq/master/support/demo/cast.gif \"Demo\")\n\n[1]: https://docs.data.nasdaq.com/docs/getting-started\n[2]: https://github.com/DannyBen/nasdaq/blob/master/lib/nasdaq/docopt.txt\n[3]: https://github.com/DannyBen/lightly\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fnasdaq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyben%2Fnasdaq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fnasdaq/lists"}