Search, fetch, and get data regarding United States presidents.

Overview

us-presidents

Search, fetch, and get data regarding United States presidents.

GitHub Documention Discord Examples

Installation

NPM
npm install us-presidents
Yarn
yarn add us-presidents

Data

import { presidents } from "us-presidents";

console.log(presidents); //Array of objects containing info about all US presidents

Note: The const { presidents } = require("us-presidents"); syntax is also supported, this applies to the functions as well.

Functions

randomPresident()

Gets a random president.

import { randomPresident } from "us-presidents";

console.log(randomPresident());

/*
Example Response:

{
  order: 23,
  name: 'Benjamin Harrison',
  description: 'Benjamin Harrison was an American lawyer and politician who served as the 23rd president of the United States from 1889 to 1893. He was a grandson of the ninth president, William Henry Harrison, and a great-grandson of Benjamin Harrison V, a founding father who signed the United States Declaration of Independence.',
  wikipedia: 'https://wikipedia.org/wiki/Benjamin_Harrison',
  term: { startYear: 1889, endYear: 1893, served: 1 },
  party: 'Republican',
  life: { birthYear: 1833, deathYear: 1901 }
}
*/
searchPresidents(query: string)

Search presidents by their name.

import { searchPresidents } from "us-presidents";

console.log(searchPresidents("donald trump")); //Returns a array of results, in this case it will only be one result
/*
[
  {
    order: 45,
    name: 'Donald Trump',
    description: 'Donald John Trump is an American politician, media personality, and businessman who served as the 45th president of the United States from 2017 to 2021.',
    wikipedia: 'https://en.wikipedia.org/wiki/Donald_Trump',
    term: { startYear: 2017, endYear: 2021, served: 1 },
    party: 'Republican',
    life: { birthYear: 1946, deathYear: null }
  }
]
*/

console.log(searchPresidents("donald trump")[0]); //Returns the first result, instead of an array of results
searchPresidentsByTerm(year: number, type: "start" | "end" = "either")

Returns an array of presidents who started and/or ended their term in a certain year.

import { searchPresidentsByTerm } from "us-presidents";

console.log(searchPresidentsByTerm(2021));
/*
Returns Donald Trump and Joe Biden because Trump's end year was 2021, and Biden's start year was 2021:
[
  {
    order: 45,
    name: 'Donald Trump',
    description: 'Donald John Trump is an American politician, media personality, and businessman who served as the 45th president of the United States from 2017 to 2021.',
    wikipedia: 'https://en.wikipedia.org/wiki/Donald_Trump',
    term: { startYear: 2017, endYear: 2021, served: 1 },
    party: 'Republican',
    life: { birthYear: 1946, deathYear: null }
  },
  {
    order: 46,
    name: 'Joe Biden',
    description: 'Joseph Robinette Biden Jr. is an American politician who is the 46th and current president of the United States. A member of the Democratic Party, he served as the 47th vice president from 2009 to 2017 under Barack Obama and represented Delaware in the United States Senate from 1973 to 2009.',
    wikipedia: 'https://en.wikipedia.org/wiki/Joe_Biden',
    term: { startYear: 2021, endYear: null, served: null },
    party: 'Democrat',
    life: { birthYear: 1942, deathYear: null }
  }
]
*/

console.log(searchPresidentsByTerm(2021, "start")); //Would just return Joe Biden

console.log(searchPresidentsByTerm(2021, "end")); //Would just return Donald Trump

console.log(searchPresidentsByTerm(null, "end")); //Would return Joe Biden as his term doesn't have an end year yet
searchPresidentsByLife(year: number, type: "birth" | "death" = "either")

Returns an array of presidents who were born and/or diseased in a certain year.

import { searchPresidentsByLife } from "us-presidents";

console.log(searchPresidentsByLife(1732)); //Returns an array of anyone who was born or diseased in 1732, in this case only George Washington
console.log(searchPresidentsByLife(1946, "birth")); //Returns an array of any president who was born in 1946, Bill Clinton; Donald Trump; and George W. Bush
console.log(searchPresidentsByLife(null, "death")); //Returns an array of every president who is still alive
searchPresidentsByParty(partyName: party)

Returns an array of all presidents of a certain party.

import { searchPresidentsByParty } from "us-presidents";

console.log(searchPresidentsByParty("Republican")); //Returns an array of all presidents of the Republican party
console.log(searchPresidentsByParty("Democrat")); //Returns an array of all presidents of the Democrat party
You might also like...

A personal semantic search engine capable of surfacing relevant bookmarks, journal entries, notes, blogs, contacts, and more, built on an efficient document embedding algorithm and Monocle's personal search index.

A personal semantic search engine capable of surfacing relevant bookmarks, journal entries, notes, blogs, contacts, and more, built on an efficient document embedding algorithm and Monocle's personal search index.

Revery 🦅 Revery is a semantic search engine that operates on my Monocle search index. While Revery lets me search through the same database of tens o

Dec 30, 2022

A script for Obsidian's QuickAdd plugin, to fetch books data using Google Books API.

A script for Obsidian's QuickAdd plugin, to fetch books data using Google Books API.

Books script for Obsidian's Quickadd plugin Demo If this script helped you and you wish to contribute :) Description This script allows you to easily

Dec 31, 2022

Instant spotlight like search and actions in your browser with Sugu Search.

Instant spotlight like search and actions in your browser with Sugu Search.

Sugu Search Instant spotlight like search and actions in your browser with Sugu Search. Developed by Drew Hutton Grab it today for Firefox and Chrome

Oct 12, 2022

An efficient (and the fastest!) way to search the web privately using Brave Search Engine

Brave Search An efficient (and the fastest) way to search the web privately using Brave Search Engine. Not affiliated with Brave Search. Tested on Chr

Jun 2, 2022

🍭 search-buddy ultra lightweight javascript plugin that can help you create instant search and/or facilitate navigation between pages.

🍭 search-buddy ultra lightweight javascript plugin that can help you create instant search and/or facilitate navigation between pages.

🍭 search-buddy search-buddy is an open‑source ultra lightweight javascript plugin (* 1kb). It can help you create instant search and/or facilitate n

Jun 16, 2022

🟢 Music player app with a modern homepage, fully-fledged music player, search, lyrics, song exploration features, search, popular music around you, worldwide top charts, and much more.

🟢 Music player app with a modern homepage, fully-fledged music player, search, lyrics, song exploration features, search, popular music around you, worldwide top charts, and much more.

Music-player-app see the project here. 1. Key Features 2. Technologies I've used Key Features: 🟢 Fully responsive clean UI. 🟢 Entirely mobile respo

Nov 16, 2022

Tesodev-search-app - Personal Search App with React-Hooks

Tesodev-search-app - Personal Search App with React-Hooks

Tesodev-search-app Personal Search App with React-Hooks View on Heroku : [https://tesodev-staff-search-app.herokuapp.com/] Instructions Clone this rep

Nov 10, 2022

Node starter kit for semantic-search. Uses Mighty Inference Server with Qdrant vector search.

Node starter kit for semantic-search.  Uses Mighty Inference Server with Qdrant vector search.

Mighty Starter This project provides a complete and working semantic search application, using Mighty Inference Server, Qdrant Vector Search, and an e

Oct 18, 2022

Allows users to quickly search highlighted items on Wikipedia. Inspired by the "search Wikipedia" function on the kindle mobile app.

Allows users to quickly search highlighted items on Wikipedia. Inspired by the

wikipedia-search Allows users to quickly search highlighted items on Wikipedia. Inspired by the "search Wikipedia" function on the kindle mobile app.

Aug 15, 2022
Owner
Spen
Hello, I'm Spen. I enjoy coding and writing.
Spen
An enchanced useState hook which keeps track of the states history, allowing you to undo and redo states.

useTimeline An enchanced useState hook which keeps track of the states history, allowing you to undo and redo states. useTimeline is a simple hook bas

null 13 Apr 22, 2022
"Jira Search Helper" is a project to search more detail view and support highlight than original jira search

Jira Search Helper What is Jira Search Helper? "Jira Search Helper" is a project to search more detail view and support highlight than original jira s

null 41 Dec 23, 2022
Node.js module for verifying Plumo proofs and reading states based on it

plumo-verifier Node.js module for verifying Plumo proofs and reading states based on it. Plumo is a SNARK-based light client verifier for the Celo blo

Celo 3 Dec 15, 2022
Mailbox is the predictable states & transitions container for actors.

Mailbox (turns XState Machine into a REAL Actor) Mailbox is an NPM module built on top of the XState machine, by adding a message queue to the XState

Huan (李卓桓) 40 Aug 24, 2022
Promise-based utility to control modal states in React

Promise-based utility to control modal states in React Zero-dependency library that easily integrates with your existing UI components and allows you

Thiago Zanivan 8 Dec 5, 2022
This simple project aims to connect to an API to fetch score data and display it on a LeaderBoard box, as well as provide the tool to submit a new score.

Leader Board: Hit the API! This simple project aims to connect to an API to fetch score data and display it on a LeaderBoard box, as well as provide t

Andrés Felipe Arroyave Naranjo 12 Apr 6, 2022
"Choose your Pokemon" is a Webpack project meant to fetch data from two different APIs: PokéAPI and Involvement API

"Choose your Pokemon" is a Webpack project meant to fetch data from two different APIs: PokéAPI and Involvement API. Here we display a list of 20 Pokemons for whom one can like, display more info, and comment; all based on the data from these two external resources.

Carlos HerverSolano 19 Mar 31, 2022
Script to fetch all NFT owners using moralis API. This script output is a data.txt file containing all owner addresses of a given NFT and their balances.

?? Moralis NFT Snapshot Moralis NFT API will only return 500 itens at a time when its is called. For that reason, a simple logic is needed to fetch al

Phill Menezes 6 Jun 23, 2022
fetch and process data in web worker, store in indexedDB.

Query+ install yarn add query-plus or pnpm add query-plus or npm install query-plus import import { useFetch, usePreFetch } from "query-plus" use

Rod Lewis 5 Aug 29, 2022