Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
wikipedia-api
Advanced tools
Readme
This code exports a set of functions to interact with the Wikipedia API. The functions include:
Suggest Wikipedia article titles matching the input query. The function returns the list
of suggestions and the status
of the response.
The function accepts one parameter:
query
: A string
representing the search to be performedThe function uses the Fetch API to send an HTTP request to the Wikipedia API and returns the result as a JSON object. If the HTTP request returns a status other than 200
, the function returns a response with a status of 400
and an undefined
result.
const autocompleteResult:IAutocomplete = await autocomplete('batman');
console.log('autocompleteResult =>', autocompleteResult);
Search Wikipedia articles matching the input query. The function returns the search results
, a suggestion
if available, and the status
of the response.
The function accepts two parameters:
query
: A string
representing the search to be performed.limit
: An optional number
that indicates the maximum number of results to receive. By default, this number is 10
. The max value is 500
.The function uses the Fetch API to send an HTTP request to the Wikipedia API and returns the result as a JSON object. If the HTTP request returns a status other than 200
, the function returns a response with a status of 400
and an undefined
result.
const searchResult:ISearch = await search('batman');
console.log('searchResult =>', searchResult);
const searchResult:ISearch = await search('batman', 50);
console.log('searchResult =>', searchResult);
Retrieve information about a specific page using the REST API. The function returns the title
, the content
of the article, and the status
of the response.
The function accepts one parameter:
query
: A string
representing the search to be performed.The function uses the Fetch API to send an HTTP request to the Wikipedia API and returns the result as a JSON object. If the HTTP request returns a status other than 200
, the function returns a response with a status of 400
and an undefined
result.
const pageResult:IPage = await page('batman');
console.log('pageResult =>', pageResult);
Retrieve information about a specific page using the the older version of Wikipedia . The function returns the result
of the page, and the status
of the response.
The function accepts one parameter:
query
: A string
representing the title of the page you want to retrieve information about.The function uses the Fetch API to send an HTTP request to the Wikipedia API and returns the result as a JSON object. If the HTTP request returns a status other than 200
, the function returns a response with a status of 400
and an undefined
result.
const pageOldResult:IPageOld= await pageOld('superman');
console.log('pageOldResult =>', pageOldResult);
Retrieve a list of events that happened ont the same day of the month. The function returns the list
of events, the type
of events, and the status
of the response.
The function accepts three parameters:
type
:onThisDayType
This parameter specifies the type of information to be fetched. It can be one of the following: 'all', 'selected', 'births', 'deaths', 'events', 'holidays'
. The default value is 'all'
.month
: string
This parameter specifies the month for which the information is to be fetched. The default value is the current month.2
or 02
.day
: string
This parameter specifies the day for which the information is to be fetched. The default value is the current day.2
or 02
.The function uses the Fetch API to send an HTTP request to the Wikipedia API and returns the result as a JSON object. If the HTTP request returns a status other than 200
, the function returns a response with a status of 400
and an undefined
result.
const onThisDayResult:IOnThisDay = await onThisDay();
console.log('onThisDayResult =>', onThisDayResult?.result);
const onThisDayResult:IOnThisDay = await onThisDay('deaths');
console.log('onThisDayResult =>', onThisDayResult?.result?.deaths);
const onThisDayResult:IOnThisDay = await onThisDay('deaths', '01', '01');
console.log('onThisDayResult =>', onThisDayResult?.result?.deaths);
Retrieve information about the hyperlink, The function returns an object
of type IPopupItem
and the status
of the response.
The function accepts one parament:
query
: A string
representing the search to be performed.The function uses the Fetch API to send an HTTP request to the Wikipedia API and returns the result as a JSON object. If the HTTP request returns a status other than 200
, the function returns a response with a status of 400
and an undefined
result.
const popupResult:IPopup = await popup('batman');
console.log('popupResult =>', popupResult);
FAQs
wikipedia api
The npm package wikipedia-api receives a total of 1 weekly downloads. As such, wikipedia-api popularity was classified as not popular.
We found that wikipedia-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.