Hello API

View in API Explorer

Using JsonServiceClient in Web Pages

The easiest way to call your APIs in a webpage is to include your JavaScript DTOs /types/js and built-in UMD @servicestack/client library:

<script src="/js/require.js"></script>
<script src="/js/servicestack-client.js"></script>
<script src="/types/js"></script>

We can then import and use the library and DTO types:

var { JsonServiceClient, Hello } = exports

var client = new JsonServiceClient()
client.api(new Hello({ name }))
    .then(function(api) {
        if (api.succeeded) 

Using @servicestack/client in npm projects

Update your App's TypeScript DTOs and compile to JS (requires TypeScript):

$ x scripts dtos

Including @servicestack/client & Typed DTOs

Where you'll be able to use your APIs typed DTOs with ServiceStack's generic **JsonServiceClient**

$ npm install @servicestack/client
import { JsonServiceClient } from '@servicestack/client'
import { Hello } from './dtos'

let client = new JsonServiceClient()
let api = await client.api(new Hello({ name }))
if (api.succeeded) 

Typed DTOs generated using TypeScript Add ServiceStack Reference