• This repository has been archived on 16/Apr/2020
  • Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    CoffeeScript
  • License
    Other
  • Created over 12 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Http Client to deal easily with JSON API

About

Request is a great HTTP client for NodeJS, but if you deal only with JSON, things could be more straightforward. This lib aims to simplify Request usage for JSON only requests.

Install

Add it to your package.json file or run in your project folder:

npm install request-json --save

Build status

Build Status

How it works

request = require('request-json');
var client = request.createClient('http://localhost:8888/');

var data = {
  title: 'my title',
  content: 'my content'
};
client.post('posts/', data, function(err, res, body) {
  return console.log(res.statusCode);
});

client.get('posts/', function(err, res, body) {
  return console.log(body.rows[0].title);
});

data = {
  title: 'my new title'
};
client.put('posts/123/', data, function(err, res, body) {
  return console.log(res.statusCode);
});

client.del('posts/123/', function(err, res, body) {
  return console.log(res.statusCode);
});

data = {
  title: 'my patched title'
};
client.patch('posts/123/', data, function(err, res, body) {
  return console.log(res.statusCode);
});

Note: Previously you should call newClient() but now it is renamed to createClient(). You still can use newClient() though it will throw deprecation message.

Extra: files

data = {
  name: "test"
};
client.sendFile('attachments/', './test.png', data, function(err, res, body) {
  if (err) {
    return console.log(err);
  }
});

client.saveFile('attachments/test.png', './test-get.png', function(err, res, body) {
  if (err) {
    return console.log(err);
  }
});

sendFile can support file path, stream, array of file path and array of streams. Each file is stored with the key 'file + index' (file0, file1, file2...) in the request in case of array. For a single value, it is stored in the field with key 'file'. If you use a stream, it must have a "path" attribute containing its path or filename.

Extra: basic authentication

client.setBasicAuth('john', 'secret');
client.get('private/posts/', function(err, res, body) {
  return console.log(body.rows[0].title);
});

Extra: headers manipulation

client.headers['Cookie'] = 'Your cookie';

Extra: promises

client.get('posts/')
  .then(function(result) {
    console.log(result.res.statusCode);
    console.log(result.body); 
  }).catch(err) {
    console.log(err);
  }
});

Who uses it

request-json and request-json-light are downloaded more than 50 000 times each month. Here are the companies which use it for their API clients:

More Repositories

1

cozy-stack

Simple, Versatile, Yours
Go
1,117
star
2

cozy-setup

Cozy installation files and information
Python
818
star
3

cozy

Simple, Versatile, Yours
454
star
4

cozy-drive

Cozy Drive Web App for Cozy Cloud
JavaScript
170
star
5

cozy-home-v2

This repository was part of CozyV2 which has been deprecated
JavaScript
95
star
6

cozy.github.io

Official documentation for Cozy.
Python
88
star
7

americano

Deprecated - Make Express.js more opinioniated about configuration
CoffeeScript
71
star
8

cozy-calendar

An application to manage your events
JavaScript
67
star
9

cozy-emails

Email Client for Cozy
CoffeeScript
66
star
10

cozy-banks

A Banks Aggregator on Cozy
JavaScript
59
star
11

cozy-home

A cozy client application to configure and run cozy konnectors
JavaScript
50
star
12

cozy-ui

React components and CSS styles for Cozy apps
JavaScript
48
star
13

prosemirror-go

A port in Go of ProseMirror for writing a collaborative editing server
Go
45
star
14

cozy-files

This repository was part of CozyV2 which has been deprecated
JavaScript
41
star
15

cozy-ical

ICal Parser and Calendar models for Cozy Cloud
CoffeeScript
29
star
16

cozy-vcard

Cozy-vcard provides vcard Parser and Objects
CoffeeScript
29
star
17

cozy-mobile

Cordova based mobile client for cozy-files
CoffeeScript
27
star
18

cozy-photos-v2

Deprecated - New : https://github.com/cozy/cozy-drive/tree/master/src/photos - Personal Photo Gallery Manager
JavaScript
27
star
19

cozy-proxy

This repository was part of CozyV2 which has been deprecated - Cozy authentication and routing layer
CoffeeScript
26
star
20

cozy-data-system

Deprecated - Data Layer for Cozy V2 Platform
CoffeeScript
24
star
21

gozy-docker

Sample configuration file to run Gozy inside a Docker container
Dockerfile
23
star
22

notes

Note manager
JavaScript
23
star
23

cozy-contacts-v2

Contact books manager for Cozy
CoffeeScript
20
star
24

todos

Simple task management application
JavaScript
20
star
25

cozy-docs

Deprecated - Go to https://github.com/cozy/cozy-docs-v3
HTML
19
star
26

cozy-tutorial

Source to illustrate The "Make your own app" Tutorial
JavaScript
18
star
27

cozy-dev

Archived - Please use https://github.com/CPatchane/create-cozy-app
CoffeeScript
17
star
28

create-cozy-app

A CLI to bootstrap a "zero-configuration" application for the Cozy V3 platform
JavaScript
16
star
29

cozy-monitor

A tool to manage your Cozy Platform from the command line.
CoffeeScript
15
star
30

simple-cozy

Cozy without the market place
CoffeeScript
14
star
31

cozy-data-indexer

[DEPRECATED] REST API for data indexation
Python
14
star
32

cozy-template

Deprecated use https://github.com/cpatchane/cozy-create-app. Template project to create an application for the Cozy Platform
JavaScript
14
star
33

cozy-client

Document store and React components for the Cozy platform
JavaScript
13
star
34

cozy-debian

Cozy Debian package
Shell
13
star
35

cozy-self-hosting

An application to manage self hosted application on an Debian
JavaScript
12
star
36

cozy-guidelines

Cozy Code Guidelines
11
star
37

cozy-site

Official repository for the Cozy website.
HTML
11
star
38

cozy-notes

TypeScript
11
star
39

cozy-client-js

Javascript library to write Cozy applications
JavaScript
11
star
40

cozy-template-coffee

Template project for Cozy Applications written with Coffeescript
CoffeeScript
10
star
41

cozy-contacts

Contact manager for Cozy Cloud
JavaScript
10
star
42

cozy-editor

A cozy text editor
JavaScript
9
star
43

jugglingdb-cozy-adapter

[DEPRECATED] Jugglingdb adapter for connection with the Cozy Data System
CoffeeScript
9
star
44

cozy-flagship-app

TypeScript
8
star
45

cozy-stack-compose

Docker-compose for cozy-stack
Shell
8
star
46

cozy-coclyco

Tools to manage gozy instances
Python
7
star
47

cozy-browser-sdk

Cozy Data System client for the browser
CoffeeScript
7
star
48

cozy-libs

Libraries used to build Cozy products and tools.
JavaScript
7
star
49

coachCO2

CoachCO2 aims to raise user awareness about their carbon footprint, notably based on their transport data.
JavaScript
7
star
50

cozy-bar

cozy-bar.js library, a small lib provided by cozy-stack to inject the Cozy-bar component into each app
JavaScript
7
star
51

cozy-db

Cozy Data System Driver
CoffeeScript
6
star
52

cozy-store

Marketplace app for the Cozy platform
JavaScript
6
star
53

cozy-ghost-theme

Cozy theme for Ghost
Handlebars
6
star
54

debian-cozy

Cozy Debian packaging
Shell
6
star
55

printit

Dirty logging with class
JavaScript
6
star
56

cozy-registry

Deprecated, please use https://github.com/cozy/cozy-apps-registry
JavaScript
5
star
57

cozy-controller

Cozy Module and Apps deployer
CoffeeScript
5
star
58

ACH

Import/Export data from your Cozy
JavaScript
4
star
59

cozy-settings

Settings app for Cozy Cloud
JavaScript
4
star
60

cozy-pass-mobile

Mobile app to access your Cozy Vault - based on https://github.com/bitwarden/mobile
C#
4
star
61

cozy-clients

Helper Clients to access easily to Cozy APIs
CoffeeScript
3
star
62

cozy-sandbox

Developer tool to test and experiment with Cozy Intents
JavaScript
3
star
63

couchdb-debian

JavaScript
3
star
64

cozy-apps-registry

A home for Cozy applications and connectors
Go
3
star
65

cozy-slug

Slugify your strings
CoffeeScript
3
star
66

cozy-papillon-app

JavaScript
3
star
67

cozy-device-sdk

CoffeeScript
2
star
68

cozy-clearance

Clearance manager for cozy apps
JavaScript
2
star
69

cozy-bootstrap

Cozy Bootstrap is a theme for Bootstrap with Cozy look and colors.
SCSS
2
star
70

cozy-move

Wizard for moving a Cozy from one place to another
Elixir
2
star
71

cozy-doctypes

The doctypes used in cozy-stack
2
star
72

cozy-passwords

⚠️ This project is now in 'cozy-pass-web' repository
JavaScript
2
star
73

sidekiq-workflow

Sidekiq workflow manager
Ruby
2
star
74

mespapiers

JavaScript
2
star
75

cordova-plugin-calendarsync

Cordova adnroid calendar syncadapter plugin
Java
2
star
76

americano-cozy

[DEPRECATED] Helpers for Cozy Applications based on Americano
CoffeeScript
2
star
77

cozy-fixtures

Deprecated - Manage easily the data fixtures for your Cozy developments!
CoffeeScript
1
star
78

cozy-photos-v3

Cozy Photos app for Cozy Cloud
JavaScript
1
star
79

cozy-indexer

Full text indexing library for cozy
CoffeeScript
1
star
80

cozy-docdev-v3

Developer documentation of Cozy V3
1
star
81

CozyShareExtension

Android Share Extension files - must be integrated AFTER Cordova project generation
Java
1
star
82

cordova-jsbackgroundservice

Java
1
star
83

cozy-url-sdk

CoffeeScript
1
star
84

pouchdb-playground

Make queries with PouchDB and measure performances
JavaScript
1
star
85

cozy-i18n-helper

Helper library for i18n in Cozy Application
CoffeeScript
1
star
86

template-es6

Template project for Cozy Applications written with ES6
JavaScript
1
star
87

editor-core

This is forked from the sourcefiles (ts) of @atlaskit/editor-core.
TypeScript
1
star
88

debian-cozy-coclyco

Coclyco Debian packaging
Makefile
1
star
89

python_cozy_management

Python module to manage self hosted cozy
Python
1
star
90

dissec_cozy

Python
1
star
91

debian-cozy-desktop

Cozy Desktop Debian packaging
Makefile
1
star
92

cozy-home-backup

[DEPRECATED] Main Dashboard for the Cozy Plaform
JavaScript
1
star
93

CozyActionExtension

iOS extension for Cozy Drive
Objective-C
1
star
94

react-native-document-scanner

Scan documents with phone camera
Java
1
star