fredapi


Namefredapi JSON
Version 0.5.2 PyPI version JSON
download
home_pagehttps://github.com/mortada/fredapi
SummaryPython API for Federal Reserve Economic Data (FRED) from St. Louis Fed
upload_time2024-05-05 11:42:11
maintainerNone
docs_urlNone
authorMortada Mehyar
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements pandas
Travis-CI No Travis.
coveralls test coverage No coveralls.
            fredapi: Python API for FRED (Federal Reserve Economic Data)
============================================================

``fredapi`` is a Python API for the
`FRED <http://research.stlouisfed.org/fred2/>`__ data provided by the
Federal Reserve Bank of St. Louis. ``fredapi`` provides a wrapper in
python to the `FRED web
service <http://api.stlouisfed.org/docs/fred/>`__, and also provides
several conveninent methods for parsing and analyzing point-in-time data
(i.e. historic data revisions) from
`ALFRED <http://research.stlouisfed.org/tips/alfred/>`__

``fredapi`` makes use of ``pandas`` and returns data to you in a
``pandas`` ``Series`` or ``DataFrame``

Installation
------------

.. code:: sh

    pip install fredapi

Basic Usage
-----------

First you need an API key, you can `apply for
one <http://api.stlouisfed.org/api_key.html>`__ for free on the FRED
website. Once you have your API key, you can set it in one of three
ways:

-  set it to the evironment variable FRED\_API\_KEY
-  save it to a file and use the 'api\_key\_file' parameter
-  pass it directly as the 'api\_key' parameter

.. code:: python

    from fredapi import Fred
    fred = Fred(api_key='insert api key here')
    data = fred.get_series('SP500')

Working with data revisions
---------------------------

Many economic data series contain frequent revisions. ``fredapi``
provides several convenient methods for handling data revisions and
answering the quesion of what-data-was-known-when.

In `ALFRED <http://research.stlouisfed.org/tips/alfred/>`__ there is the
concept of a *vintage* date. Basically every *observation* can have
three dates associated with it: *date*, *realtime\_start* and
*realtime\_end*.

-  date: the date the value is for
-  realtime\_start: the first date the value is valid
-  realitime\_end: the last date the value is valid

For instance, there has been three observations (data points) for the
GDP of 2014 Q1:

.. code:: xml

    <observation realtime_start="2014-04-30" realtime_end="2014-05-28" date="2014-01-01" value="17149.6"/>
    <observation realtime_start="2014-05-29" realtime_end="2014-06-24" date="2014-01-01" value="17101.3"/>
    <observation realtime_start="2014-06-25" realtime_end="2014-07-29" date="2014-01-01" value="17016.0"/>

This means the GDP value for Q1 2014 has been released three times.
First release was on 4/30/2014 for a value of 17149.6, and then there
have been two revisions on 5/29/2014 and 6/25/2014 for revised values of
17101.3 and 17016.0, respectively.

Get first data release only (i.e. ignore revisions)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

    data = fred.get_series_first_release('GDP')

Get latest data
~~~~~~~~~~~~~~~

Note that this is the same as simply calling ``get_series()``

.. code:: python

    data = fred.get_series_latest_release('GDP')

Get latest data known on a given date
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python

    fred.get_series_as_of_date('GDP', '6/1/2014')

Get all data release dates
~~~~~~~~~~~~~~~~~~~~~~~~~~

This returns a ``DataFrame`` with all the data from ALFRED

.. code:: python

    df = fred.get_series_all_releases('GDP')
    df.tail()

Get all vintage dates
~~~~~~~~~~~~~~~~~~~~~

.. code:: python

    vintage_dates = fred.get_series_vintage_dates('GDP')

Search for data series
~~~~~~~~~~~~~~~~~~~~~~

You can always search for data series on the FRED website. But sometimes
it can be more convenient to search programmatically. ``fredapi``
provides a ``search()`` method that does a fulltext search and returns a
``DataFrame`` of results.

.. code:: python

    fred.search('potential gdp')

You can also search by release id and category id with various options

.. code:: python

    df1 = fred.search_by_release(11)
    df2 = fred.search_by_category(101, limit=10, order_by='popularity', sort_order='desc')

Dependencies
------------

-  `pandas <http://pandas.pydata.org/>`__

More Examples
-------------

- I have a `blog post with more examples <http://mortada.net/python-api-for-fred.html>`__ written in an `IPython` notebook

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mortada/fredapi",
    "name": "fredapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Mortada Mehyar",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/6f/3c/e9281ecda4c6ee5c7d50a4bcf00dc5df1a7ff325e604c9b9510c5bdd8514/fredapi-0.5.2.tar.gz",
    "platform": "Any",
    "description": "fredapi: Python API for FRED (Federal Reserve Economic Data)\n============================================================\n\n``fredapi`` is a Python API for the\n`FRED <http://research.stlouisfed.org/fred2/>`__ data provided by the\nFederal Reserve Bank of St. Louis. ``fredapi`` provides a wrapper in\npython to the `FRED web\nservice <http://api.stlouisfed.org/docs/fred/>`__, and also provides\nseveral conveninent methods for parsing and analyzing point-in-time data\n(i.e. historic data revisions) from\n`ALFRED <http://research.stlouisfed.org/tips/alfred/>`__\n\n``fredapi`` makes use of ``pandas`` and returns data to you in a\n``pandas`` ``Series`` or ``DataFrame``\n\nInstallation\n------------\n\n.. code:: sh\n\n    pip install fredapi\n\nBasic Usage\n-----------\n\nFirst you need an API key, you can `apply for\none <http://api.stlouisfed.org/api_key.html>`__ for free on the FRED\nwebsite. Once you have your API key, you can set it in one of three\nways:\n\n-  set it to the evironment variable FRED\\_API\\_KEY\n-  save it to a file and use the 'api\\_key\\_file' parameter\n-  pass it directly as the 'api\\_key' parameter\n\n.. code:: python\n\n    from fredapi import Fred\n    fred = Fred(api_key='insert api key here')\n    data = fred.get_series('SP500')\n\nWorking with data revisions\n---------------------------\n\nMany economic data series contain frequent revisions. ``fredapi``\nprovides several convenient methods for handling data revisions and\nanswering the quesion of what-data-was-known-when.\n\nIn `ALFRED <http://research.stlouisfed.org/tips/alfred/>`__ there is the\nconcept of a *vintage* date. Basically every *observation* can have\nthree dates associated with it: *date*, *realtime\\_start* and\n*realtime\\_end*.\n\n-  date: the date the value is for\n-  realtime\\_start: the first date the value is valid\n-  realitime\\_end: the last date the value is valid\n\nFor instance, there has been three observations (data points) for the\nGDP of 2014 Q1:\n\n.. code:: xml\n\n    <observation realtime_start=\"2014-04-30\" realtime_end=\"2014-05-28\" date=\"2014-01-01\" value=\"17149.6\"/>\n    <observation realtime_start=\"2014-05-29\" realtime_end=\"2014-06-24\" date=\"2014-01-01\" value=\"17101.3\"/>\n    <observation realtime_start=\"2014-06-25\" realtime_end=\"2014-07-29\" date=\"2014-01-01\" value=\"17016.0\"/>\n\nThis means the GDP value for Q1 2014 has been released three times.\nFirst release was on 4/30/2014 for a value of 17149.6, and then there\nhave been two revisions on 5/29/2014 and 6/25/2014 for revised values of\n17101.3 and 17016.0, respectively.\n\nGet first data release only (i.e. ignore revisions)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    data = fred.get_series_first_release('GDP')\n\nGet latest data\n~~~~~~~~~~~~~~~\n\nNote that this is the same as simply calling ``get_series()``\n\n.. code:: python\n\n    data = fred.get_series_latest_release('GDP')\n\nGet latest data known on a given date\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    fred.get_series_as_of_date('GDP', '6/1/2014')\n\nGet all data release dates\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis returns a ``DataFrame`` with all the data from ALFRED\n\n.. code:: python\n\n    df = fred.get_series_all_releases('GDP')\n    df.tail()\n\nGet all vintage dates\n~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    vintage_dates = fred.get_series_vintage_dates('GDP')\n\nSearch for data series\n~~~~~~~~~~~~~~~~~~~~~~\n\nYou can always search for data series on the FRED website. But sometimes\nit can be more convenient to search programmatically. ``fredapi``\nprovides a ``search()`` method that does a fulltext search and returns a\n``DataFrame`` of results.\n\n.. code:: python\n\n    fred.search('potential gdp')\n\nYou can also search by release id and category id with various options\n\n.. code:: python\n\n    df1 = fred.search_by_release(11)\n    df2 = fred.search_by_category(101, limit=10, order_by='popularity', sort_order='desc')\n\nDependencies\n------------\n\n-  `pandas <http://pandas.pydata.org/>`__\n\nMore Examples\n-------------\n\n- I have a `blog post with more examples <http://mortada.net/python-api-for-fred.html>`__ written in an `IPython` notebook\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python API for Federal Reserve Economic Data (FRED) from St. Louis Fed",
    "version": "0.5.2",
    "project_urls": {
        "Homepage": "https://github.com/mortada/fredapi"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73641db43417cf7ed430f104a347126b5260a1724ee9a1b7d0b1622262c9c4df",
                "md5": "813f16bdab375eaa02e83647fbda63dd",
                "sha256": "961817ec8d70e58886ff7302d3dda908614ad99f77831a59833c4fc3f6150155"
            },
            "downloads": -1,
            "filename": "fredapi-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "813f16bdab375eaa02e83647fbda63dd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11854,
            "upload_time": "2024-05-05T11:42:09",
            "upload_time_iso_8601": "2024-05-05T11:42:09.559855Z",
            "url": "https://files.pythonhosted.org/packages/73/64/1db43417cf7ed430f104a347126b5260a1724ee9a1b7d0b1622262c9c4df/fredapi-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f3ce9281ecda4c6ee5c7d50a4bcf00dc5df1a7ff325e604c9b9510c5bdd8514",
                "md5": "19446db22701120efdf75f025176eb15",
                "sha256": "405ca048abed4207d93dbc9b7ee8c46d6b473483650323e2f1c094af83d4b247"
            },
            "downloads": -1,
            "filename": "fredapi-0.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "19446db22701120efdf75f025176eb15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14735,
            "upload_time": "2024-05-05T11:42:11",
            "upload_time_iso_8601": "2024-05-05T11:42:11.444418Z",
            "url": "https://files.pythonhosted.org/packages/6f/3c/e9281ecda4c6ee5c7d50a4bcf00dc5df1a7ff325e604c9b9510c5bdd8514/fredapi-0.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-05 11:42:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mortada",
    "github_project": "fredapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pandas",
            "specs": [
                [
                    ">=",
                    "0.15"
                ]
            ]
        }
    ],
    "lcname": "fredapi"
}
        
Elapsed time: 0.23615s