<commit_before># wpcom.js

  [WordPress.com][] JavaScript API client designed for Node.JS and
  browsers.

## How to use

### Node.JS

Introduce the `wpcom` dependency in your `package.json`, and
then initialize it with your API Token.

```js
var wpcom = require('wpcom')('<your-token>');
var blog = wpcom.site('your-blog.wordpress.com');
blog.posts({ number: 8 }, function(err, list){});
```

### Browser

Include `dist/wpcom.js` in a `<script>` tag:

```html
<script src="wpcom.js"></script>
<script>
  var wpcom = WPCOM('<your-token>');
  var blog = wpcom.site('your-blog.wordpress.com');
  blog.posts({ number: 8 }, function(err, list){});
</script>
```

## API

### new WPCOM('token');

Create a new instance of WPCOM. `token` parameter is optional but it's needed to
make admin actions or to access to protected resources.

**Note**: You can use the [node-wpcom-oauth][] module to get an _access token_.

### WPCOM#me()

Create a `Me` object. More info in [Me doc page](./docs/me.md).

```js
var wpcom = require('wpcom')('<your-token>');
var me = wpcom.me();

// get user information
me.get(function(err, info){
});
```

### WPCOM#site('site-id')

Create a `Site` object. More info in [Site doc page](./docs/site.md).

```js
var wpcom = require('wpcom')('<your-token>');
var site = wpcom.site();

// get blog posts
site.posts(function(err, list){
});
```

### WPCOM#freshlyPressed([query], fn)

View Freshly Pressed posts from the WordPress.com homepage.

```js
wpcom.freshlyPressed(function(err, data){
  if (err) throw err;
  console.log('"Freshly Pressed" Posts:');
  data.posts.forEach(function (post) {
    console.log('  %s - %s', post.title, post.short_URL);
  });
});
```


## Examples

[Examples](./examples/Readme.md) doc page

## Test

Create `data.json` file into `test/` folder to can run the tests. You can copy
or rename the `test/data_example.json` file.

```json
{
  "token": {
    "global": "<global token>"
  },

  "site": {
    "public": {
      "url": "<public blog url>"
    },
    "private" : {
      "url": "<private blog url>",
      "id": "<private blog id>",
      "private": "<token>"
    }
  },<commit_msg>doc: clean main doc file<commit_after># wpcom.js

  [WordPress.com][] JavaScript API client designed for Node.JS and
  browsers.

## How to use

### Node.JS

Introduce the `wpcom` dependency in your `package.json`, and
then initialize it with your API Token.

```js
var wpcom = require('wpcom')('<your-token>');
var blog = wpcom.site('your-blog.wordpress.com');
blog.posts({ number: 8 }, function(err, list){});
```

### Browser

Include `dist/wpcom.js` in a `<script>` tag:

```html
<script src="wpcom.js"></script>
<script>
  var wpcom = WPCOM('<your-token>');
  var blog = wpcom.site('your-blog.wordpress.com');
  blog.posts({ number: 8 }, function(err, list){});
</script>
```

## API

### new WPCOM('token');

Create a new instance of WPCOM. `token` parameter is optional but it's needed to
make admin actions or to access to protected resources.

**Note**: You can use the [node-wpcom-oauth][] module to get an _access token_.

### API Sections

* [Core]('./docs/core.md')
* [Me]('./docs/me.md')
* [Site]('./docs/site.md')
* [Post]('./docs/post.md')
* [Media]('./docs/media.md')

## Examples

[Examples](./examples/Readme.md) doc page

## Test

Create `data.json` file into `test/` folder to can run the tests. You can copy
or rename the `test/data_example.json` file.

```json
{
  "token": {
    "global": "<global token>"
  },

  "site": {
    "public": {
      "url": "<public blog url>"
    },
    "private" : {
      "url": "<private blog url>",
      "id": "<private blog id>",
      "private": "<token>"
    }
  },
{'fraction_non_alphanumeric': 0.19629225736095965, 'fraction_numerical': 0.0010905125408942203, 'mean_word_length': 3.7464424320827945, 'pattern_counts': {'":': 16, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4681619', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1277, 'n_words': 382}