Dittofi
  • Tutorials
    • Tutorial Index
    • Quick Start
    • Dittofi Essentials
      • Part 1: Frontend terms and concepts
      • Part 2: Backend terms and concepts
      • Part 3: Connecting frontend and backend
      • Part 4: Dittofi app structure
    • Dittofi App Design
      • 🏗️App architecture 101
      • ◼️Backend app development 101
      • 🟪Frontend app development 101
      • 🔰(optional) Web developer beginner series
  • Learn Frontend
    • 👨‍💻Getting Started
      • Welcome to Dittofi
      • Intro to the Dittofi Design Studio (Frontend)
    • 🟩Pages
    • 🟪Elements
      • Types
        • Button Element
        • Div Block Element
        • Form Block Element
        • Link Block Element
        • List Element
        • Modal Box Element
        • Tabs Element
        • Columns Element
        • Image Element
      • Partials
      • Prefabs
      • Custom
    • 🟧Variables
      • Array
      • Checkbox
      • Collection
      • Collection (Custom Model)
      • Collection (System Custom Model)
      • Custom Model
      • Date
      • Datetime
      • File
      • Json
      • Number
      • Number with decimal
      • Model
      • System Custom Model
      • Text
      • UUID
    • 🟨Events
      • 🟨External
        • HTTP Request
        • Run Endpoint
      • 🟨Flow Control
        • Condition
        • Run Action
        • Loop
        • Sleep
      • 🟨Maths
        • Add
        • Divide
        • Modulus
        • Multiply
        • Subtract
      • 🟨Navigation
        • Open Page
      • 🟨Notifications
        • Alert
        • Confirm
      • 🟨Other
        • Copy To Clipboard
        • Run Custom
      • 🟨Text
        • Concat
        • Contains
        • Ends With
        • I Contains
        • I Ends With
        • I Starts With
        • LTrim
        • RTrim
        • Text To Upper
        • Text To Lower
        • Trim
        • Starts With
      • 🟨Variables
        • Set Field
        • Remove Field
      • Validate
    • 🟦CSS Layouts
      • Holy Grail Layout
      • Side Bar Layout
      • Sticky Footer Layout
      • Sticky Header Layout
      • CSS Frameworks
    • 🔲CSS Frameworks
    • Component Libraries
    • Meta Attributes
  • Learn Backend
    • 🖥️Getting Started
      • Intro to Data
      • Intro to APIs
      • Build your first custom API
      • Actions & Events
    • 🟫Back-End Actions
    • 🟩Custom Models
      • 🟩Attributes
        • Array
        • Checkbox
        • Custom Model
        • Collection (Custom Model)
        • Collection (System Custom Model)
        • Date
        • Datetime
        • File
        • Number
        • Number With Decimal
        • Json
        • Text
    • ◼️Data Models
      • Database Fundamentals
        • Database relationships
      • ◼️Columns
        • Attachment
        • Auto Increment
        • Checkbox
        • Date
        • Datetime
        • Duration
        • Email
        • Long text
        • Link to another record field
        • Number
        • Number with decimal
        • Password
        • Phone number
        • Percent
        • Price
        • Rating
        • Single select
        • Single line text
        • URL
    • 🟥Events
      • 🟦Arrays
        • Append
        • Array Pop
        • At
        • Length
        • Prepend
        • Range
      • 🟦Conversions
        • Base64 Encode
        • Base64 Decode
        • Json Decode
        • Json Encode
        • Path Escape
        • Path Unescape
        • Query Escape
        • Query String Parse
        • Query Unescape
        • To Bool
        • To Float
        • To Int
        • To Str
        • Yaml Encode
        • Yaml Decode
      • 🟦Database Requests
        • Create
        • Create Or Update
        • Delete
        • Has Record
        • Read Event
        • Update
      • 🟦External
        • HTTP Request
        • SFTP Download
        • SFTP Upload
      • 🟦Files
        • CSV Reader Event
        • CSV Writer Event
        • File Read
        • File Save
        • File Size
        • File Type
        • JSON Reader
        • PDF Generator
      • 🟦Flow Control
        • Condition
        • Loop
        • Return
        • Run Action
        • Sleep
      • 🟦Notifications
        • Send Mail
        • Connect Websocket
        • Message Websocket
      • 🟦Maths
        • Add
        • Acos
        • Acosh
        • Asin
        • Asinh
        • Atan
        • Atanh
        • Cbrt
        • Ceil
        • Divide
        • Modulus
        • Multiply
        • Subtract
      • 🟦Security
        • Compare Password
        • JWT Decode
        • JWT Encode
        • Login
        • Logout Web User
        • Password Generator
        • Random Number
      • 🟦Time
        • Add Time
        • Day
        • Format Time
        • Minute
        • Nanosecond
        • Parse Time
        • Second
        • Time In
        • Year
        • Year Day
      • 🟦Text
        • Concat
        • Contains
        • Ends With
        • Execute Template
        • I Contains
        • I Ends With
        • I Starts With
        • Starts With
        • LTrim
        • RTrim
        • Replace
        • Regex Find All String
        • Regex Find String
        • Regex Match String
        • Trim
        • Text To Lower
        • Text To Upper
        • Text To Title
        • Url Getarg
      • 🟦Other
        • Assign
        • Run Custom
        • Redirect Web Page Event
        • Render Web Template Event
    • 🟧Variables
      • Array
      • Checkbox
      • Collection
      • Collection (Custom Model)
      • Collection (System Custom Model)
      • Custom Model
      • Date
      • Datetime
      • File
      • Json
      • Number
      • Number with decimal
      • Model
      • System Custom Model
      • Text
      • UUID
    • 🟪Webservices
  • Templates
    • Two sided marketplace template
      • Introduction
        • Part I: Installing and setting up the marketplace template
        • Part II: Understanding what features are included in the marketplace template
        • Part III: Customizing your marketplace frontend without coding
        • Exploring Dittofi's marketplace API
      • Listings
        • How to create a marketplace listing
    • How to build a CRUD app
  • Third Party APIs
    • OAuth 2.0 APIs
      • Introduction To OAuth 2.0
      • Google OAuth 2.0 - PART I
      • Google OAuth 2.0 - PART II
  • Dittofi Admin
    • Your Account
      • Workspace Admin
      • Manage Billing
      • Connect a custom domain
      • How to use a discount code to Dittofi Pro
  • FAQ
    • API Generator
    • How to write custom SQL?
    • Why does my image not display?
    • How can I set up Google Analytics?
    • Exporting and deploying my frontend code
    • What is a partial and what is a prefab?
    • How to set up a basic mulit tenant app on Dittofi
    • How to write a custom endpoint in Dittofi
    • How to integrate Font Awesome into Dittofi
    • How can I set up Dittofi to run on my own private server?
    • How to add roles such as Super Admin, Admin, Manager & User
    • How to prevent duplicate records being added to the database
    • What to do when relation cannot be created because their is violating data in the referenced table
  • Change Logs
    • Dittofi Change Logs
Powered by GitBook
On this page
  • Understanding JSONPlaceholder API
  • Dittofi Webservices

Was this helpful?

  1. Learn Backend

Webservices

PreviousUUIDNextTwo sided marketplace template

Last updated 2 years ago

Was this helpful?

The is a simple & free API for testing & prototyping. In this section, we are going to connect to the API from inside the Dittofi Design Studio.

In this tutorial we will cover:

  1. Understanding JSONPlaceholder API

  2. Dittofi Webservices

Understanding JSONPlaceholder API

You can read about the JSONPlacerholder API @ . The information provided tells us that API is filled with fake data that we can use for testing.

The API comes with eight API endpoints which it calls "Routes". These are shown below.

Breaking down the URL here, we see again that we have:

Dittofi Webservices

Dittofi gives you the tools to connect to a third party API. To access these tools, go to the Web Services tab, under the tools icon.

Clicking on Web Services will bring up the following page.

To create a new web service (A) click "+ New Webservice" & (B) click "New Webservice".

This brings up a screen where you can configure your new webservice.

The screen is split into two parts. On the left hand side, you can specify the protocol that you will use to connect to the third party API. The options are HTTP & HTTPS. You can also enter the Host part of the URL that you're interested to connect to.

Next, we can turn our attention to the right hand side of the screen.

This is where we are going to add the different API endpoints that we are going to connect to. For example "GET /posts", "GET /posts/1/comments", "GET /comments?postsid=1" etc.

To begin with, let's add the "GET /posts" endpoint. To do this, we must begin by configuring the "Basic" settings of our webservice as below.

The grid below explains what each of the options are.

Option

Description

Example

Name

The name that we give to this endpoint. It doesn't matter what name you set, but it should be something meaningful.

Get JSONPlacholder API Posts

HTTP Method

This is the method that is set on the API Endpoint. You can read this in the API documentation.

Get

Path

The path of your URL.

/posts

Resp. Variable

The data that is returned from the Get request must be inserted into a variable that conforms to the shape of the data in the API.

Collection (custom model)

In the example above, we have not yet created a our Resp. Variable (response variable). To do this, head on over to the Custom Models tab. This can be found below the tools icon in the toolbar.

Clicking on Custom Models brings us to the Custom Models tab, as below.

Inside the Custom Models tab, you're able to build or generate custom data structures that can be used to store data temporarily. In our case we want to take the data that will be returned from the JSONPlaceholder API & stick it into a variable.

To generate a custom model to map your data into, you can use the following 5 steps, starting from Generating the model through to inspecting the new Custom Model.

Next, we step back to the Webservice tab & set the response variable for our API Endpoint to equal our new custom model.

Ditto Tip: Notice, we set the Kind to Collection (custom model). This is because we are expecting a list of JSON objects back from the API when we request the data. Collections inside Dittofi are like lists.

Press save & the API Endpoint has been setup.

Testing the API Endpoint

To test the API Endpoint, we can create our own endpoint, action & event to run an HTTP request. The video below shows this happening.

Users can click on each of the options to see examples of the data that lives at the end of each of the GET endpoints. For example, clicking on returns.

This should look familiar to the JSON data that we saw in .

In order to get this data, we had to go to the URL . Notice that this URL breaks down into two parts.

The Host will always remain the same. This is the address where the system we are connecting to is being hosted. But the Path will change, depending on which part of the system we are looking to access via the API Endpoints. For example, if we want to get the comments, we need to use the endpoint "".

In our case we want to connect to the JSONPlaceholder API. Reading their website, we can see that their API supports either HTTP or HTTPS & we already know that the Host is . So we configure our webservice in the following way & press save.

Notice, that the response in our endpoint is equal to the data at the JSONPlaceholder API Endpoint .

🟪
GET /posts
Intro to APIs
https://jsonplaceholder.typicode.com/posts
GET /posts/1/comments
jsonplaceholder.typicode.com
GET /v1/posts
JSONPlaceholder API
https://jsonplaceholder.typicode.com/