# Check URL Safety with Google Safe Browsing API

## Pipedream makes it easy to connect APIs for Google Safe Browsing and 3,000+ other apps remarkably fast.

Trigger workflow on
- HTTP requests, schedules and app events

Next, do this
- Check URL Safety with the Google Safe Browsing API

No credit card required

▶

Watch us build a workflow

8 min

### Trusted by 1,000,000+ developers from startups to Fortune 500 companies

## Developers ♥ Pipedream

### Getting Started

Create a workflow to Check URL Safety with the Google Safe Browsing API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

1. **Configure** the Check URL Safety action
2. Connect your `Google Safe Browsing` account
3. Select one or more `Threat Types`
4. Select one or more `Platform Types`
5. Select one or more `Threat Entry Types`
6. Configure `Threat Entries`
7. **Select a trigger** to run your workflow on HTTP requests, schedules or app events
8. **Deploy** the workflow
9. **Send a test event** to validate your setup
10. **Turn on** the trigger

### Details

This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

Check URL Safety on Google Safe Browsing

- **Description:** Scan a given URL or URLs for potential security threats. [See the documentation](https://developers.google.com/safe-browsing/v4/reference/rest/v4/threatMatches/find)
- **Version:** 0.0.2
- **Key:** google_safebrowsing-check-url-safety

### Code

```javascript
import safebrowsing from "../../google_safebrowsing.app.mjs";

export default {
  key: "google_safebrowsing-check-url-safety",
  name: "Check URL Safety",
  description: "Scan a given URL or URLs for potential security threats. [See the documentation](https://developers.google.com/safe-browsing/v4/reference/rest/v4/threatMatches/find)",
  version: "0.0.2",
  annotations: {
    destructiveHint: false,
    openWorldHint: true,
    readOnlyHint: true,
  },
  type: "action",
  props: {
    safebrowsing,
    threatTypes: {
      propDefinition: [
        safebrowsing,
        "threatTypes",
      ],
    },
    platformTypes: {
      propDefinition: [
        safebrowsing,
        "platformTypes",
        (c) => ({
          threatTypes: c.threatTypes,
        }),
      ],
    },
    threatEntryTypes: {
      propDefinition: [
        safebrowsing,
        "threatEntryTypes",
        (c) => ({
          threatTypes: c.threatTypes,
          platformTypes: c.platformTypes,
        }),
      ],
    },
    threatEntries: {
      type: "string[]",
      label: "Threat Entries",
      description: "An array of URLs to be checked",
    },
  },
  async run({ $ }) {
    const threatEntries = this.threatEntries.map((entry) => ({
      url: entry,
    }));
    const data = {
      threatInfo: {
        threatTypes: this.threatTypes,
        platformTypes: this.platformTypes,
        threatEntryTypes: this.threatEntryTypes,
        threatEntries,
      },
    };
    const response = await this.safebrowsing.findThreatMatches({
      data,
      $,
    });

if (response) {
      $.export("$summary", `Successfully scanned ${threatEntries.length} URL${threatEntries.length === 1
        ? ""
        : "s"}`);
    }

return response;
  },
};
```

### Configuration

This component may be configured based on the `props` defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.

| Label              | Prop                     | Type          | Description                                               |
| ------------------ | ----------------------- | -------------- | --------------------------------------------------------- |
| Google Safe Browsing | `safebrowsing`           | `app`          | This component uses the Google Safe Browsing app.        |
| Threat Types       | `threatTypes`           | `string[]`     | Select a value from the drop down menu.                   |
| Platform Types     | `platformTypes`         | `string[]`     | Select a value from the drop down menu.                   |
| Threat Entry Types | `threatEntryTypes`      | `string[]`     | Select a value from the drop down menu.                   |
| Threat Entries     | `threatEntries`         | `string[]`     | An array of URLs to be checked                             |

### Authentication

Google Safe Browsing uses API keys for authentication. When you connect your Google Safe Browsing account, Pipedream securely stores the keys so you can easily authenticate to Google Safe Browsing APIs in both code and no-code steps.

To use the [Google Safebrowsing API](https://developers.google.com/safe-browsing), you must [Create a Project](https://support.google.com/cloud/answer/6251787?hl=en) on Google Developer Console, then [Setup an API Key](https://support.google.com/cloud/answer/6158862?hl=en&ref_topic=6262490), and activate Google Safebrowsing APIs (see [Activate and Deactivate APIs](https://support.google.com/cloud/answer/6158841?hl=en)).

### About Google Safe Browsing

Safe Browsing is a Google service that lets client applications check URLs against Google's constantly updated lists of unsafe web resources.

### More Ways to Use Google Safe Browsing

#### Triggers

New Threat List Updated from the Google Safe Browsing API

Emit new event when a threat list is updated. [See the documentation](https://developers.google.com/safe-browsing/v4/reference/rest/v4/threatListUpdates/fetch#ListUpdateRequest)

### Actions

Get the latest threat list update information from Google Safe Browsing API. [See the documentation](https://developers.google.com/safe-browsing/v4/reference/rest/v4/threatListUpdates/fetch#ListUpdateRequest)
