Giter Club home page Giter Club logo

govinfo-link-js's Introduction

democracy-ia mascot

Apache License FOSSA Status NPM version
NSP Status Dependency Status Development Dependency Status
MacOS and Ubuntu build statuses Windows build status Coverage percentage Codacy code quality

Node.js and Web browser API Access U.S. Government Publishing Office's FDsys (Federal Digital System) content and metadata collections using the govinfo-link-js client for Node.js and Web browsers.

Table of contents

1. Install

1.1. For Node.js environments

light-bulb Download and install Node.js link-external (and its package manager, npm), if you don't have them, already.

1.1.1. Using npm

To publish the library as a npm link-external, please follow the procedure in "Publishing npm packages link-external."

Then install it via:

npm install govinfo-link-js --save

1.1.2. Using git

If the library is hosted at a git repository, e.g. https://github.com/democracy-ia/govinfo-link-js then install it via:

npm install democracy-ia/govinfo-link-js --save

code Designers and developers: additional installation instructions

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your govinfo-link-js from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('govinfo-link-js') in javascript files from the directory you ran the last command above from.


1.2. For browsers

The library also works in the browser environment via npm and browserify link-external. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

1.3. Webpack configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

2. Usage

light-bulb View all govinfo-link-js API references (with usage examples).

const { CodeOfFederalRegulations } = require('govinfo-link-js')

const api = new CodeOfFederalRegulations()

// {Number} Title number
const titlenum = 3

// {String} Part number.
const partnum = '100'

const opts = {
  /**
   * @prop {String} sectionnum - This is the section number. Sample value is 1.
   *    If section number is not provided the entire part will be returned.
   */
  sectionnum: null,

  /**
   * @prop {String} year - This is the four digit numerical year OR mostrecent.
   *    If year is not provided, the most recent version of the CFR section
   *    or part is returned. Default is most recent.
   */
  year: '2011',

  /**
   * @prop {string=pdf} [linkType] - This is the format of the returned
   *    document. Default is pdf. Other values are xml, mods, premis,
   *    details, context, related.
   */
  linkType: 'xml'
}

api.cfrFetchUsingGET(titlenum, partnum, opts, (error, data) => {
  if (error) {
    console.error(error)
  } else {
    console.log(`✅  Returned data: ${api.toJson(data)}`)
  }
})

3. API

The link service is used to create embedded links to content and metadata on govinfo and is currently enabled for the collections below. More information about each query, including examples, is provided on each collection page.

3.1. Models

  1. API reference CodeOfFederalRegulations: Code of Federal Regulations
  2. API reference CompilationOfPresidentialDocuments: Compilation of Presidential Documents
  3. API reference CongressionalBills: Congressional Bills
  4. API reference CongressionalCalendars: Congressional Calendars
  5. API reference CongressionalCommitteePrints: Congressional Committee Prints
  6. API reference CongressionalDocuments: Congressional Documents
  7. API reference CongressionalHearings: Congressional Hearings
  8. API reference CongressionalRecordDaily: Congressional Record Daily
  9. API reference CongressionalReports: Congressional Reports
  10. API reference FederalRegister: Federal Register
  11. API reference PublicAndPrivateLaws: Public and Private Laws
  12. API reference StatutesAtLarge: Statutes at Large
  13. API reference UnitedStatesCode: United States Code

3.2. Endpoints

info All HTTP request URIs are relative to https://www.govinfo.gov/link.

Class Method HTTP request
govinfo. CodeOfFederalRegulations cfrFetchUsingGET GET /cfr/{titlenum}/{partnum}

Parameters: title number, part number, section number, year OR most recent
govinfo. CompilationOfPresidentialDocuments cpdDcpdFetchUsingGET GET /cpd/{year}

Parameters: dcpd type OR dcpd number
govinfo. CompilationOfPresidentialDocuments cpdFetchUsingGET GET /cpd/{doctype}/{docnum}

Parameters: document type, document number
govinfo. CongressionalBills billsFetchUsingGET GET /bills/{congress}/{billtype}/{billnum}

Parameters: bill number, bill type, congress, bill version OR most recent
govinfo. CongressionalCalendars ccalFetchUsingGET GET /ccal/{chamber}/{section}

Parameters: chamber, section, publish date OR most recent
govinfo. CongressionalCommitteePrints cprtHouseFetchUsingGET GET /cprt/{congress}/house/{printnum}/{committee}

Parameters: congress, chamber, house print number, committee
govinfo. CongressionalCommitteePrints cprtJacketFetchUsingGET GET /cprt/{congress}/{jacketid}

Parameters: congress, jacket number
govinfo. CongressionalCommitteePrints cprtSenateFetchUsingGET GET /cprt/{congress}/senate/{printnum}

Parameters: congress, chamber, senate print number
govinfo. CongressionalDocuments cdocFetchUsingGET GET /cdoc/{congress}/{doctype}/{docnum}

Parameters: congress, document type, document number
govinfo. CongressionalDocuments cdocJacketFetchUsingGET GET /cdoc/{congress}/{jacketid}

Parameters: congress, jacket number
govinfo. CongressionalHearings chrgHouseFetchUsingGET GET /chrg/{congress}/house/{committee}/{serialnumber}

Parameters: congress, chamber, committee, house serial number
govinfo. CongressionalHearings chrgJacketFetchUsingGET GET /chrg/{congress}/{jacketid}

Parameters: congress, jacket number
govinfo. CongressionalHearings chrgSenateFetchUsingGET GET /chrg/{congress}/senate/{hearingnumber}

Parameters: congress, chamber, senate hearing number
govinfo. CongressionalRecordDaily crecSectionFetchUsingGET GET /crec/section/{section}

Parameters: section, publish date OR most recent
govinfo. CongressionalRecordDaily crecTypeFetchUsingGET GET /crec/cas/{congress}/{billtype}/{billnum}

Parameters: congress, bill number, bill type
govinfo. CongressionalRecordDaily crecTypeFetchUsingGET1 GET /crec/type/{type}

Parameters: document type, publish date OR most recent
govinfo. CongressionalRecordDaily crecVolumeFetchUsingGET GET /crec/{volume}/{pageprefix}/{page}

Parameters: volume, page prefix, page number
govinfo. CongressionalReports crptBillFetchUsingGET GET /crpt/{congress}/{associatedbillnum}

Parameters: associated bill, congress
govinfo. CongressionalReports crptReportFetchUsingGET GET /crpt/{congress}/{doctype}/{reportnum}

Parameters: congress, report type, report number
govinfo. FederalRegister frDocFetchUsingGET GET /fr/{frdocnum}

Parameters: Federal Register document number
govinfo. FederalRegister frVolumeFetchUsingGET GET /fr/{volume}/{page}

Parameters: volume, page number
govinfo. PublicAndPrivateLaws plawBillFetchUsingGET GET /plaw/{congress}/{associatedbillnum}

Parameters: associated bill number, congress
govinfo. PublicAndPrivateLaws plawStatuteFetchUsingGET GET /plaw/{statutecitation}

Parameters: Statutes at Large citation
govinfo. PublicAndPrivateLaws plawTypeFetchUsingGET GET /plaw/{congress}/{lawtype}/{lawnum}

Parameters: congress, law type, law number
govinfo. StatutesAtLarge statuteTypeFetchUsingGET GET /statute/{congress}/{lawtype}/{lawnum}

Parameters: congress, law type, law number
govinfo. StatutesAtLarge statuteVolumeFetchUsingGET GET /statute/{volume}/{page}

Parameters: volume, page number
govinfo. UnitedStatesCode uscodeFetchUsingGET GET /uscode/{title}/{section}

Parameters: title number, type, section, year OR most recent

4. Contribute

PRs Welcome We welcome contributions with GitHub issues and pull requests.


Request a feature Report a defect

Read the CONTRIBUTING guidelines


Contributions in the form of GitHub pull requests are welcome. Before embarking on a significant change, please adhere to the following guidelines:

  1. Create an issue—e.g., a defect ("bug") report or a feature request—to propose changes.

    Exceptions:

    If you're working on documentation and fixing something simple like a typo or an easy bug, go ahead and make a pull request.

  2. Follow the CONTRIBUTING guidelines.

    Why:

    Standards and guidelines make communication easier. If you're willing and able to program—or want to learn how— following the guidelines will increase the likelihood of adding your changes to the software product.

  3. Read the Code of Conduct.

    Why:

    It's more fun when everybody's friendly and respectful.

  4. Make a pull request link-external when you're ready for other to review your changes (or you get stuck somewhere).

    PR novices:

    🙋 Never created a pull request? No problem. 🆓 Take this free online training link-external. (It even covers most of the conventions in the CONTRIBUTING guidelines!)

5. License

Apache 2.0

FOSSA Status

govinfo-link-js's People

Contributors

gregswindle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

govinfo-link-js's Issues

refactor(client): use unmodified javascript-client from swagger-codegen

Submit an Issue

1. Defect or Feature?

⌦ Are you requesting a feature or reporting a defect?
⌦ Type "Defect" below for bugs, errors, or faulty behavior.
⌦ Type "Feature" for new enhancements.

Feature

2. User story summary

⌦ Describe what you want to accomplish {do something},
⌦ in what role/capacity {role},
⌦ and why it's important to you {achieve value}.

As a Maintainer,
I want to use the javascript-client from swagger-codegen without modifications
In order to increase time-to-market whenever the govinfo-link-service Swagger specification (swagger.json) is upgraded.

3. Acceptance criteria

⌦ Acceptance criteria define things that must be true when this feature is delivered.

Example: Job Applicants receive a confirmation email after they submit their resumes.

feat(json): convert FDsys xml to json (and visa versa)

Submit an Issue

1. Defect or Feature

⌦ Are you requesting a feature or reporting a defect?
⌦ Type "Defect" below for bugs, errors, or faulty behavior.
⌦ Type "Feature" for new enhancements.

✍🏽Feature

2. User story summary

⌦ Describe what you want to accomplish {do something},
⌦ in what role/capacity {role},
⌦ and why it's important to you {achieve value}.

✍🏽As a developer,
✍🏽I want the option to use JSON instead of XML
✍🏽In order to deliver faster value-to-market and time-to-market.

3. Acceptance criteria

⌦ Acceptance criteria define things that must be true when this feature is delivered.

Example: Job Applicants receive a confirmation email after they submit their resumes.

  • 1. All API methods have the option to retrieve GovInfo as JSON.

3. Notes

⌦ If you have additional comments, suggestions, or proposed solutions,
⌦ please write them below.

✍🏽 xml2js looks good.

Going with xml-js, instead.

feat(analytics): track API usage with Google Analytics

Feature request

1. User story summary

⌦ Describe what you want to accomplish {do something},
⌦ in what role/capacity {role},
⌦ and why it's important to you {achieve value}.

As a maintainer,
I want to know how the community uses govinfo-link-js
In order to repair defects and improve quality.

2. Acceptance criteria

⌦ Acceptance criteria define things that must be true when this feature is delivered.

Example: Job Applicants receive a confirmation email after they submit their resumes.

  • 1. A democracy-ia account exists on Google Analytics (GA).
  • 2. Custom dimensions for OS, Node Version, and App Version exist.
  • 3. A valid GA tracking code exists.
  • 4. govinfo-link-js uses yeoman/insight to track usage.
  • 5. Valid reports appear on Google Analytics.
  • 6. @democracy-ia/maintainers traffic are excluded from GA whenever people are acting in the role of Team Maintainer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.