Skip to content
Newer
Older
100644 158 lines (128 sloc) 4.78 KB
1d4541f @shripadk dev: added Readme.md
authored
1 # Nexmo Node API
2
3 Nexmo is a cloud based SMS API that lets you send
4 and receive high volume of messages at wholesale rates.
5
6 ## How to Install
7
8 sudo npm install node-nexmo-api
9
10 ## How to use
11
12 ```js
13 var nexmo = require('nexmo').Nexmo({key: 'your-key', secret: 'your-secret'});
14
15 nexmo.sms.send({
16 from: 'your-nexmo-number-here',
17 to: 'receiver-number-here',
18 type: 'text',
19 text: 'Hello World!'
20 }, function(err, response) {
2ea4107 @shripadk dev: more info to Readme
authored
21 /**
22 Sample Response:
23 { 'message-count': '1',
24 messages:
25 [ { 'message-price': '0.00450000',
26 status: '0',
27 'message-id': '05861BCE',
28 'remaining-balance': '1.32350000',
29 statusText: 'Success',
30 meaning: 'The message was successfully accepted for delivery by nexmo' } ] }
31 */
1d4541f @shripadk dev: added Readme.md
authored
32 });
33 ```
34 Look at the `test/` directory for more examples.
35
41ead6b @shripadk dev: fix Readme.md
authored
36 Before running tests change the values in the `test/fixtures` folder.
1d4541f @shripadk dev: added Readme.md
authored
37
38 To run the tests:
ab9b604 @shripadk dev: fix Readme.md
authored
39
41ead6b @shripadk dev: fix Readme.md
authored
40 make test
1d4541f @shripadk dev: added Readme.md
authored
41
3065970 @shripadk dev: filled some info into Readme. bumping version accomodating some …
authored
42 API
43 ---
44
45 Account
46 ---
47
48 ### Get Balance ###
49 ```js
50 // Retrieve your current account balance
51 nexmo.account.getBalance(function(err, res) { ... });
52 ```
53
54 ### Get Pricing (use Country Codes) ###
55 ```js
56 // Retrieve Nexmo's outbound pricing for a given country
57 nexmo.account.getPricing('IN', function(err, res) { ... });
58 ```
59
60 ### Update Settings ###
61 ```js
62 // Update your account settings
63 nexmo.account.updateSettings({
64 newSecret: 'max8char', // Optional. Your new API secret (8 characters max)
65 moCallBackUrl: 'http://mycallback.servername', // Optional. Inbound call back URL
66 drCallBackUrl: 'http://mycallback.servername' // Optional. DLR call back URL
67 }, function(err, res) { ... });
68
69 // want it to be much simpler?
70
71 nexmo.account.updateSecret('max8char', function(err, res) { ... });
72 nexmo.account.updateMOCallbackURL('http://mycallback.servername', function(err, res) { ... });
73 nexmo.account.updateDRCallbackURL('http://mycallback.servername', function(err, res) { ... });
74 ```
75
76 ### Get Numbers ###
77 ```js
78 // Get all inbound numbers associated with your Nexmo Account
79 nexmo.account.getNumbers(function(err, res) { ... });
80 ```
81
82 Number
83 ---
84
85 ### Number - search ###
86 ```js
87 // Get available inbound numbers for a given country
88 // Required parameters: country-code (ex: ES).
89 // Optional parameter: pattern (ex: 7000)
90 nexmo.number.search('ES', 7000, function(err, res) { ... });
91 nexmo.number.search('ES', function(err, res) { ... });
92 ```
93
94 ### Number - buy ###
95 ```js
96 // Purchase a given inbound number
97 // Required parameters:
98 // country-code : Country code (ex: ES).
99 // msisdn : An available inbound number (ex: 34911067000)
100 // Response:
101 // Http Status 200 if successful purchase
102 // Http Status 401 if wrong credentials
103 // Http Status 420 if wrong parameters
104 nexmo.number.buy('ES', 34911067000, function(err, res) { ... });
105 ```
106
107 ### Number - cancel ###
108 ```js
748a663 @shripadk dev: fix
authored
109 // Cancel an inbound number
3065970 @shripadk dev: filled some info into Readme. bumping version accomodating some …
authored
110 // Required parameters:
111 // country-code : Country code (ex: ES).
112 // msisdn : An available inbound number (ex: 34911067000)
113 // Response:
d7ab923 @shripadk dev: fix Readme
authored
114 // Http Status 200 if successful cancellation
3065970 @shripadk dev: filled some info into Readme. bumping version accomodating some …
authored
115 // Http Status 401 if wrong credentials
116 // Http Status 420 if wrong parameters
ad7f1a7 @shripadk dev: fix.
authored
117 nexmo.number.cancel('ES', 34911067000, function(err, res) { ... });
3065970 @shripadk dev: filled some info into Readme. bumping version accomodating some …
authored
118 ```
119
9beecc3 @shripadk dev: refactored. better type checking for callback fn. added a note a…
authored
120 Module specific settings
121 ---
122
123 ### Change Base URL (Caution: Change this only if Nexmo endpoint changes) ###
124 ```js
125 // defaults to https://rest.nexmo.com
126 nexmo.setBaseURL('https://new-endpoint.nexmo.com');
127 ```
128
3065970 @shripadk dev: filled some info into Readme. bumping version accomodating some …
authored
129 I'll be adding more examples soon, including a fun example application (probably an article?).
130 Please fork and contribute and send me pull requests.
131 This was done in 2 hours time, so there might be some bugs somewhere.
132 All tests pass for now. If you found a bug, but lazy to implement the solution don't hesitate to
133 leave behind at least a failing test so I can fix it immediately. :)
1d4541f @shripadk dev: added Readme.md
authored
134
135 ## License
136
137 (The MIT License)
138
139 Copyright (c) 2011 Shripad K <assortmentofsorts@gmail.com>
140
141 Permission is hereby granted, free of charge, to any person obtaining
142 a copy of this software and associated documentation files (the
143 'Software'), to deal in the Software without restriction, including
144 without limitation the rights to use, copy, modify, merge, publish,
145 distribute, sublicense, and/or sell copies of the Software, and to
146 permit persons to whom the Software is furnished to do so, subject to
147 the following conditions:
148
149 The above copyright notice and this permission notice shall be
150 included in all copies or substantial portions of the Software.
151
152 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
153 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
154 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
155 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
156 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
157 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
158 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.