Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to download API data from the Bureau of Labor Statistics?

    Hi,

    I would like to download API data from the Bureau of Labor Statistics. Unfortunately and surprisingly, Stata does not appear in the list of software that offer sample code:
    https://www.bls.gov/developers/api_sample_code.htm

    Note that already have an API key from the Bureau of Labor Statistics. How could I access API data from there? In particular, I am interested in average annual CPI data. Series number:
    CUUR0000SA0
    https://data.bls.gov/pdq/SurveyOutputServlet
    Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	97.0 KB
ID:	1568312



    Thanks.


  • #2
    via python
    Code:
    help python
    https://www.bls.gov/developers/api_python.htm#python2

    Comment


    • #3
      Thanks for offering a solution Bjarte. Would you be able to help me with the syntax in Stata?

      Comment


      • #4
        Hi, Francois, I cannot follow-up this. You may first test the given example python code in python, then if necessary ask on the stata list how to proceed getting data from python to Stata. To get familar with the Stata python integration see https://www.stata.com/new-in-stata/python-integration/

        Comment


        • #5
          Also, beside the Python solution, how can I access API data via Stata?

          Comment


          • #6
            Can you not use -import- to bring the text files and then filter to the series you want:

            Code:
            . import delimited  using https://download.bls.gov/pub/time.series/ap/ap.data.0.Current, clear
            (5 vars, 177,387 obs)
            
            . l in 1/2
            
                 +-------------------------------------------------------------+
                 |         series_id   year   period          value   footno~s |
                 |-------------------------------------------------------------|
              1. | APU0000701111       1995      M01          0.238          . |
              2. | APU0000701111       1995      M02          0.242          . |
                 +-------------------------------------------------------------+

            Comment


            • #7
              Thanks for bringing this up Scott. It could have been a viable solution but the web link does not provide annual data. This is what I get when I collapse by period, only months appear:
              Code:
              period    value
              M01    2.946
              M02    2.843
              M03    2.704
              M04    2.011
              M05    1.996
              M06    2.412
              M07    2.450
              M08    2.962
              M09    2.860
              M10    3.041
              M11    3.107
              M12    2.992
              Also, over the long run, I would like to understand how APIs work with Stata. This is a valuable tool that many websites offer now. Could someone provide information about API in Stata?

              Comment


              • #8
                Anyone knows how to handle APIs in Stata?

                Comment

                Working...
                X