
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
JavaScript API client for GOV.UK Content and Search APIs.
npm init mjs -y # initialise module-ready package.json
npm install govuk
// index.js;
import { SearchAPI, ContentAPI } from "govuk";
const searchApi = new SearchAPI();
const contentApi = new ContentAPI();
const results = await searchApi.get("Keeping a pet pig");
// Find the first result that is closest...
const searchItem = results.find((item) => item.title.includes("micropig"));
const contentItem = await contentApi.get(searchItem.link);
console.log(contentItem);
node index.js
<!-- index.html -->
<script type="module">
import { SearchAPI, ContentAPI } from "https://unpkg.com/govuk";
const searchApi = new SearchAPI();
const contentApi = new ContentAPI();
const results = await searchApi.get("Keeping a pet pig");
// Find the first result that is closest...
const searchItem = results.find((item) => item.title.includes("micropig"));
const contentItem = await contentApi.get(searchItem.link);
console.log(contentItem);
</script>
Implements the GOV.UK Content API.
Get a content item.
| Parameter | Type | Required | Description |
|---|---|---|---|
| path | string | true | The path to the content on GOV.UK e.g for https://www.gov.uk/register-to-vote you’d use register-to-vote |
Returns a content item from a promise or emitted by the 'data' event.
import { ContentAPI } from "govuk";
const api = new ContentAPI();
const contentItem = await api.get("Register-to-vote");
console.log(contentItem);
import { ContentAPI } from "govuk";
const api = new ContentAPI();
api.on("data", (contentItem) => {
console.log(contentItem);
});
api.get("Register-to-vote");
Implements the GOV.UK Search API.
Use the search API to get useful information about GOV.UK content
Set the default query and options for all other calls to get, getAll and total methods
| Parameter | Type | Required |
|---|---|---|
| queryOrOptions | string | Options | true |
| [options] | Options | false |
import { SearchAPI } from "govuk";
const api = new SearchAPI("Micro pig", { count: 10 });
const searchResults = await api.get();
console.log(searchResults);
Get first page of search items for a query
| Parameter | Type | Required |
|---|---|---|
| queryOrOptions | string | Options | true |
| [options] | Options | false |
import { SearchAPI } from "govuk";
const api = new SearchAPI();
const searchResults = await api.get("Micro pig");
console.log(searchResults);
import { SearchAPI } from "govuk";
const api = new SearchAPI();
api.on("data", (searchResults) => {
console.log(searchResults);
});
api.get("Micro pig");
Get all pages of search items for a query.
| Parameter | Type | Required | Description |
|---|---|---|---|
| queryOrOptions | string | Options | true | |
| [options] | Options | false | |
| options.total | number | false | maximum amount of results |
import { SearchAPI } from "govuk";
const api = new SearchAPI();
const searchResults = await api.getAll("Micro pig");
console.log(searchResults);
import { SearchAPI } from "govuk";
const api = new SearchAPI();
api.on("data", (searchResults) => {
console.log(searchResults);
});
api.getAll("Micro pig");
Get metadata for a content item.
| Parameter | Type | Required | Description |
|---|---|---|---|
| path | string | true | The path to the content on GOV.UK e.g for https://www.gov.uk/register-to-vote you’d use register-to-vote |
import { SearchAPI } from "govuk";
const api = new SearchAPI();
const contentInfo = await api.info("register-to-vote");
console.log(contentInfo);
Get total amount of search items for a query.
| Parameter | Type | Required |
|---|---|---|
| queryOrOptions | string | Options | true |
| [options] | Options | false |
import { SearchAPI } from "govuk";
const api = new SearchAPI();
const totalResults = await api.total("Micro pig");
console.log(totalResults);
Get facets for a field.
| Parameter | Type | Required |
|---|---|---|
| field | string | true |
import { SearchAPI } from "govuk";
const api = new SearchAPI();
const facets = await api.facets("formats");
console.log(facets);
You can use any options available in the Search API.
| Name | Type | Description |
|---|---|---|
| q | string | search query |
| Name | Type | Description |
|---|---|---|
| start | number | position to start |
| count | number | number of results to return |
| order | string | sort order |
| Name | Type | Description |
|---|---|---|
| fields | Array | properties to return in search item |
| Name | Type | Description |
|---|---|---|
| filter.[field] | string | field to filter by |
| aggregate.[field] | string | field to aggregate by |
| reject.[field] | string | field to reject by |
| facet.[field] | string | group by field |
FAQs
JavaScript API client for GOV.UK Content and Search APIs.
The npm package govuk receives a total of 8 weekly downloads. As such, govuk popularity was classified as not popular.
We found that govuk 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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.