https://github.com/banyudu/medium-story
Fetch stories from medium.com
https://github.com/banyudu/medium-story
medium-article
Last synced: 4 months ago
JSON representation
Fetch stories from medium.com
- Host: GitHub
- URL: https://github.com/banyudu/medium-story
- Owner: banyudu
- License: mit
- Created: 2019-02-26T06:32:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T03:22:59.000Z (over 2 years ago)
- Last Synced: 2024-02-25T13:20:30.212Z (over 1 year ago)
- Topics: medium-article
- Language: TypeScript
- Homepage:
- Size: 546 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# medium-story
**medium-story** is a package used to fetch medium stories.
## Features
* Fetch stories from medium.com, by rss feed.
* Works in both browser and node environment.
* Typescript support.## Usage
### Node
```typescript
import getMediumStories from 'medium-story'async someFunc () {
const stories = await getMediumStories('Your-Medium-Username')for (const story of stories.items) {
console.log(story.title)
// title: string;
// link: string;
// pubDate: Date;
// content: string;
// creator: string;
// guid: string;
// categories: string[];
// isoDate: Date;
}
}
```### Browser
```typescript
import getMediumStories from 'medium-story'async someFunc () {
const stories = await getMediumStories('Your-Medium-Username', { cors: true })for (const story of stories.items) {
console.log(story.title)
// title: string;
// link: string;
// pubDate: Date;
// content: string;
// creator: string;
// guid: string;
// categories: string[];
// isoDate: Date;
}
}
```## Types
```typescript
export interface Story {
title: string;
link: string;
pubDate: Date;
content: string;
creator: string;
guid: string;
categories: string[];
isoDate: Date;
}
export interface StoriesResult {
items: Story[];
feedUrl: string;
image: {
link: string;
url: string;
title: string;
};
title: string;
description: string;
webMaster: string;
generator: string;
link: string;
lastBuildDate: Date;
}
declare type corsFunc = (url: string) => string;
export interface getStoriesOptions {
cors?: boolean | corsFunc;
timeout?: number;
}
export default function getStories(username: string, options?: getStoriesOptions): Promise;
export {};
```## Explain
**medium-story** use [medium feeds](https://help.medium.com/hc/en-us/articles/214874118-RSS-feeds) to get latest stories from specified account.
Thanks to [cors.io](https://cors.io/), you can use it in browser, too!
Due to medium's limit, you can only get recent **10** stories.