Skip to main content

A parser for the Federal Procurement Data System (FPDS) Atom feed

Project description

fpds

A no-frills parser for the Federal Procurement Data System (FPDS) found here.

Motivation

The only programmatic access to this data via an ATOM feed limits each request to 10 records, which forces users to deal with pagination. Additonally, data is exported as XML, which proves annoying for most developers. fpds will handle all pagination and data transformation to provide users with a nice JSON representation of the equivalent XML data.

Setup

To install this package for development, create a virtual environment and install dependencies.

$ python3.10 -m venv venv
$ source venv/bin/activate
$ pip install -e .

Usage

For a list of valid search criteria parameters, consult FPDS documentation found here. Parameters will follow the URL String format shown in the link above, with the following exceptions:

  • Colons (:) will be replaced by equal signs (=)
  • Certain parameters enclose their value in quotations. fpds will automatically determine if quotes are needed, so simply enclose your entire criteria string in quotes.

For example, AGENCY_CODE:"3600" should be used as "AGENCY_CODE=3600".

Via CLI:

$  fpds parse "LAST_MOD_DATE=[2022/01/01, 2022/05/01]" "AGENCY_CODE=7504"

By default, data will be dumped into an .fpds folder at the user's $HOME directory. If you wish to override this behavior, provide the -o option. The directory will be created if it doesn't exist:

$  fpds parse "LAST_MOD_DATE=[2022/01/01, 2022/05/01]" "AGENCY_CODE=7504" -o my-preferred-directory

Same request via python interpreter:

import asyncio
from itertools import chain
from fpds import fpdsRequest

request = fpdsRequest(
    LAST_MOD_DATE="[2022/01/01, 2022/05/01]",
    AGENCY_CODE="7504"
)

# results are nested lists so de-nest
data = asyncio.run(request.data())
records = list(chain.from_iterable(data))

For linting and formatting, we use flake8 and black.

$ make lint
$ make formatters

Lastly, you can clean the clutter and unwanted noise.

$ make clean

Testing

$ make local-test

What's New

As of 08/21/2024, v1.4.1 data is returned as a generator, providing more flexibility for memory constrained devices. Users also have the ability to select specific pages of results with the page parameter.

Parameters in fields.json have been updated to support unbounded values. Previously, range-based parameters had to define an upper & lower bound (i.e. [4250, 7500]). In the most current version of this library, you can now specify the following patterns for all range parameters: [4250,) or (, 7500]. This even works for dates: [2022/08/22,) or (, 2022/08/01]!

fpds now supports asynchronous requests! As of v1.3.0, users can instantiate the class as usual, but will now need to call the process_records method to get records as JSON. Note: due to some recursive function calls in the XML parsing, users might experience some high completion times for this function call. Recommendation is to limit the number of results.

Timing Benchmarks (in seconds):

v1.2.1 v.1.3.0
188.46 29.40
190.38 28.14
187.20 27.66

Using v.1.2.1, the average completion time is 188.68 seconds (~3min). Using v.1.3.0, the average completion time is 28.40 seconds.

This equates to a 84.89% decrease in completion time!

As of v1.3.0, fpds now supports the use of over 100 keyword tags when searching for contracts using the v1.5.3 ATOM feed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fpds-1.4.1.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

fpds-1.4.1-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file fpds-1.4.1.tar.gz.

File metadata

  • Download URL: fpds-1.4.1.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for fpds-1.4.1.tar.gz
Algorithm Hash digest
SHA256 840652935002abba7aaf1c1529ec8a41a5c8482ff295bbcbd13bc8e8548613b5
MD5 f59257108f92de2adbe97e763ba64883
BLAKE2b-256 3fa6ffaf858e0ab77e1c62e83ef0d9034bf7113b80f0d8277b8f4b5592ed5927

See more details on using hashes here.

File details

Details for the file fpds-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: fpds-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for fpds-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a86e2e9a1212ace56de55f9b2b7519c6f6336961fbd050f324b9906c3314b30a
MD5 b637e4a179518871dbfeba9460bff305
BLAKE2b-256 def9b3ab8e4d22d1f04abbe3e6b229d33b09de11225c0cb52e821b02de326f2e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page