Make Every website provides APIs.
Last updated 2 years ago by jogis .
MIT · Original npm · Tarball · package.json
$ cnpm install toapi 
SYNC missed versions from official npm registry.


Make Every website provides APIs.


Topapi is a supper slight server framework, which provide one way to ask for every website to provide apis.

We don't need to climb the website day by day. Because they should provide the API we need!

All we need is a Temme snippet.


Toapi provide multi cache for every page u visit. So, don't worry about u make a huge trivial ddos like to the website.



Get Started


git clone
cd toapi && npm install

Start Example

  • Node Require: 8.6+ to support async function
npm start
# then visit localhost:3000/job/3616345

That's all, can't be simple much more. Read more about example.


Install the NPM module:

npm install toapi


Let's say we need to visit the job detail API of lagou.

Such as

We just write a temme selector like:

.job_company@company {
  .fl{find($name|fp, '拉勾认证企业')}
  .c_feature li:nth-child(1){find($domain|fp, '领域')}
  .c_feature li:nth-child(2){find($stage|fp, '发展阶段')}
  .c_feature li:nth-child(3){find($size|fp, '规模')}
  .c_feature li:nth-child(4) a[href=$link];

If u don't know what temme is. Maybe u can ref this:

And then register it!

const ToAPI = require('toapi')

  routeName: '/job/:id',
  matchUrl: '',
  selector: selector,


All things are done, enjoy ur website swimming.


ToAPI.start(port, options)

Start the ToAPI server, u can continue to register route after server started.

  • port
    • the starting port
  • options
    • watiUntil, defaults to domcontentloaded
      • Spec the browser event that represent page data is ready.
      • more options can be see here
    • timeout, defaults to 30000
      • Spec timeout value when requesting to the target page.
// pageA will be timeout after 30000(default) ms

ToAPI.start(3000, { timeout: 60000 })

// pageB will be timeout after 60000 ms


Register the page route to be served.

  • routeName (optional)
    • The same as koa route
    • ToAPI will parse from matchUrl if not specified.
    • eample: /page/:id
  • matchUrl
    • The target website match route
    • example:
  • selector (optional)
    • The Temme Selector to spec page
  • waitUntil
    • DefaultsTo: domcontentloaded
  • timeout
    • DefaultsTo: 30000

Current Tags

  • 0.0.2                                ...           latest (2 years ago)

2 Versions

  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 0
Dependencies (15)
Dev Dependencies (1)
Dependents (0)

Copyright 2014 - 2016 © |