npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nft-image-proxy

v1.0.2

Published

An api to interact with the nft image proxy

Downloads

6

Readme

NFT Image Proxy

nft-image-proxy is a javascript/typescript api to interact with NFT Image Proxy to allow for easy image filtering and moderation.

Installation

nft-image-proxy is available via npm. Run npm install nft-image-proxy

Usage

Fetch

To fetch an image, use proxyFetch. This function takes in a server object, the url to fetch, the response type (either ImageProxyDataType.Json or ImageProxyDataType.Raw), and a force flag. If force is set to true, the image will be fetched regardless of if it contains explicit content. If it is set to false, then explicit images will be blocked and a JSON response will be returned which contains a list of moderation labels that the image was found to match with.

import {
  proxyFetch,
  ImageProxyServer,
  ImageProxyDataType,
} from "nft-image-proxy";

const server: ImageProxyServer = {
  url: "https://imgproxy-prod.cryptonomic-infra.tech",
  version: "1.0.0",
  apikey: "myapikey",
};

proxyFetch(
  server,
  "https://upload.wikimedia.org/wikipedia/commons/8/84/Michelangelo%27s_David_2015.jpg",
  ImageProxyDataType.Json,
  false
).then((response) => console.log(response));

Some convenience functions are also available. safeFetch is equivilant to proxyFetch with the force parameter set to false and unsafeFetch is equivilant to proxyFetch with the force parameter set to true.

import { safeFetch, unsafeFetch } from "nft-image-proxy";

safeFetch(server, url, ImageProxyDataType.Json).then(
  (response: FetchResponse | ImageProxyError) => console.log(response)
);

unsafeFetch(server, url, ImageProxyDataType.Json).then(
  (response: FetchResponse | ImageProxyError) => console.log(response)
);

Describe

If the image proxy has seen an image previously, it can return moderation results from its cache before fetching. describe takes in an array of url strings and returns a JSON response containing a description of each image. The status of each image can be either Blocked, Allowed, or NotSeen (if the image hasn't been cached yet).

import { describe } from "nft-image-proxy";

describe(server, [url1, url2, url3]).then(
  (response: DescribeResponse | ImageProxyError) => console.log(response)
);

Report

If an explicit image were to make it past the content moderation provider, a user could also report the image to the proxy with suggested moderation labels.

import { response } from "nft-image-proxy";

report(server, url, [ModerationLabel.Drugs, ModerationLabel.Alcohol]).then(
  (response: ReportResponse | ImageProxyError) => {
    console.log(response);
  }
);

Describe Reports

All of the current reports submitted to the image proxy can be viewed using describeReports

import { describeReports } from "nft-image-proxy";

describeReports(server).then(
  (response: DescribeReportsResponse | ImageProxyError) => console.log(response)
);

Other References

For more information about the image proxy, the request and reponse formats, or how it works, view our public repo here.