Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

the-standardizer

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

the-standardizer

Standardizes social API data models

  • 1.2.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

The Standardizer

The Standardizer's goal is to standardize API data models. This is specific to Art404's needs, but these utility scripts will convert APIs from social platforms to one we expect. It currently supports GitHub, Behance, Twitter, Tumblr, and Instagram.

Motivation

By standardizing our data model we can build components that render in a predictable way without having to code platform handling logic. Also has the added benefit of stripping JSON size down to only what we need.

Usage

standardize all

import {standardize} from 'the-standardizer'

request('myapirequestroute.com', (err, resp) => {
  if (err) console.error(err)
  else {
    // standardize the response assuming its an array of api objects
    const standardizedPosts = standardize(resp)
    // do something with resp
    someOtherFunc(standardizedPosts)
  }
})

NOTE: Expects an array of objects, usually from a single platform but mixed is fine too.

standardize specific

While standardize will automatically determine type for you, if you want to be specific you can import standardizers individually like so:

import {standardizeTumblr} from 'the-standardizer'

request('tumblr.api.com/posts/whatever', (err, resp) => {
  if (err) console.error(err)
  else {
    // standardize the Tumblr response
    const standardizedPosts = standardizeTumblr(resp)
    // do something with resp
    someOtherFunc(standardizedPosts)
  }
})

NOTE: Expects a single object from a specific platform.

Using any of the convert scripts will transform your objects into a data model that looks like so:

{
  "title": "5 Million 1 Terabyte",
  "id": 136478152056,
  "url": "5m1t",
  "priority": 900,
  "text": "A hard-drive that has 5 million dollars worth of information acquired from torrented files",
  "created_at": "2016-01-02 20:17:24 GMT",
  "type": "media",
  "source": {
    "platform": "tumblr",
    "author": "art404",
    "author_avatar": "http://pbs.twimg.com/profile_images/652614485002207232/s5s3R6ff_normal.jpg",
    "author_url": "http://art404.tumblr.com",
    "url": "http://art404.tumblr.com/5m1t"
  },
  "stats": {
    "views": null,
    "likes": 72,
    "reshares": 112
  },
  "tags": [
    "hardware",
    "data mining",
    "torrents",
    "big data",
    "piracy"
  ],
  "media": [
    {
      "type": "photo",
      "url": "http://56.media.tumblr.com/5449b95c9e036d38fd7c31d4a213784d/tumblr_o0cdp0Ml1P1sz85suo1_400.png",
      "embed": null,
      "alt_sizes": {
        "small": "http://56.media.tumblr.com/5449b95c9e036d38fd7c31d4a213784d/tumblr_o0cdp0Ml1P1sz85suo1_75sq.png",
        "medium": "http://56.media.tumblr.com/5449b95c9e036d38fd7c31d4a213784d/tumblr_o0cdp0Ml1P1sz85suo1_250.png",
        "large": "http://56.media.tumblr.com/5449b95c9e036d38fd7c31d4a213784d/tumblr_o0cdp0Ml1P1sz85suo1_500.png"
      }
    }
  ],
  "additional": {
    "collaborators": [],
    "embeds": [],
    "comments": [],
    "press": [],
    "project_link": ""
  }
}
Project Data Model Properties
PropertyTypeDefaultDescription
titleStringnullLabel to be used as project title
idNumbernoneUnique id, if source has id we use that one otherwise create one
urlStringnoneUrl slug that will be used for project detail page, manually set or generated from source
priorityNumber00-1000, will affect a projects position when creating collection previews
textStringnullRelated project copy
created_atStringnoneDate project was posted, also used in conjunction with priority to determine project position
typeStringnoneProject types dictatate what components will render them, manually set or generated from source
sourceObjectnoneContains relevant info from a project's source (where its hosted)
statsObjectnullStatistical info about project
tagsArraynoneTags are used to sort projects and create relationships
mediaArraynullExternal media links, with types and alt sizes if available
additional'Object'nullAny meta data not existant on the source manually added by contributor

FAQs

Package last updated on 06 Mar 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc