There is a good guide here on how to create your own API.
The hardest part of any API design is designing for as many use-cases as possible and to provide interfaces so that users of the library can override standard implementations (where applicable).