Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions docs/api/redditapi/RedditAPIClient/classes/RedditAPIClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@

The Reddit API Client

To use the Reddit API Client, add it to the plugin configuration at the top of the file.
To use the Reddit API Client, enable the `redditAPI` permission in your `devvit.json` file.

```json title="devvit.json"
{
"permissions": {
"redditAPI": true
}
}
```

## Example

```ts

Devvit.configure({
redditAPI: true,
// other plugins
})

// use within one of our capability handlers e.g. Menu Actions, Triggers, Scheduled Job Type, etc
async (event, context) => {
const subreddit = await context.reddit.getSubredditById(context.subredditId);
context.reddit.submitPost({
subredditName: subreddit.name,
title: 'test post',
text: 'test body',
})
// additional code
}
import { reddit } from '@devvit/web/server';

export const menuActionHandler = async () => {
const subredditName = await reddit.getCurrentSubredditName();
return await reddit.submitPost({
subredditName,
title: 'test post',
text: 'test body',
});
};
```

## Constructors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@

The Reddit API Client

To use the Reddit API Client, add it to the plugin configuration at the top of the file.
To use the Reddit API Client, enable the `redditAPI` permission in your `devvit.json` file.

```json title="devvit.json"
{
"permissions": {
"redditAPI": true
}
}
```

## Example

```ts

Devvit.configure({
redditAPI: true,
// other plugins
})

// use within one of our capability handlers e.g. Menu Actions, Triggers, Scheduled Job Type, etc
async (event, context) => {
const subreddit = await context.reddit.getSubredditById(context.subredditId);
context.reddit.submitPost({
subredditName: subreddit.name,
title: 'test post',
text: 'test body',
})
// additional code
}
import { reddit } from '@devvit/web/server';

export const menuActionHandler = async () => {
const subredditName = await reddit.getCurrentSubredditName();
return await reddit.submitPost({
subredditName,
title: 'test post',
text: 'test body',
});
};
```

## Constructors
Expand Down
Loading