This presentation, originally delivered by Django developer Charlotte Mays at DjangoCon 2017, covers what an API is, why APIs are useful, and how to build one of your own using the Django Rest Framework.
More and more web projects require interfacing with the backend using a REST-ful interface. In this presentation we'll discuss Django-REST-Framework's features and walk through how to integrate it into your next project!
More and more web projects require interfacing with the backend using a REST-ful interface. In this presentation we'll discuss Django-REST-Framework's features and walk through how to integrate it into your next project!
Apache Sling as an OSGi-powered REST middlewareRobert Munteanu
Apache Sling is an innovative web framework built on top of the Java Content Repository (JCR), that uses OSGi for its component model and fosters RESTful application design.
This presentation will showcase how the Apache Sling framework can be used to build a unified REST-based middleware for multiple data sources, such as MongoDB, Apache Cassandra, Apache Jackrabbit Oak or classical relational databases. In doing so it will present the benefits that come from a single Resource API over multiple data stores, both at the library level and at the HTTP boundary.
Effective Web Application Development with Apache SlingRobert Munteanu
Apache Sling is an innovative web framework built on top of the Java Content Repository (JCR), that uses OSGi for its component model and fosters RESTful application design.
This talk shows how Sling integrates various standard-based technologies, like OSGi and the Content Repository API for Java to create a coherent framework for web application development. We will walk through the development of a simple application with minimal effort and demonstrate how to productize the resulting application.
We will pay special attention to some approaches which are not yet part of mainstream development, such as using OSGi for dependecy injection and JCR for persistence.
With Grails 3, the plugin development experience changes a little bit compared to that of Grails 2. In this talk, Álvaro (member of the Grails team at OCI, Grails committer and author of several plugins) will cover several topics to understand how plugins work in Grails 3, focusing on best practices.
The session is structured as a set of tips and tricks with code samples in the following areas: modularisation, build system, testing and publishing.
Building domain-specific testing tools : lessons learned from the Apache Slin...Robert Munteanu
The Apache Sling project has built a number of testing tools which aid in testing applications that are built on top of this framework - REST-based, assembled using OSGi and backed by JCR.
We will review how those testing tools fit in with domain-agnostic testing tools such as JUnit and Mockito and what the benefits and pitfalls are when building your own domain-specific tools.
Similar techniques apply to projects not using the same technology stack, so the discussion will bring value to all projects which can benefit from domain-specific testing tools.
CIRCUIT 2015 - 10 Things Apache Sling Can DoICF CIRCUIT
Presented by Carsten Ziegeler & David Bosschaert from Adobe
Apache Sling is the underlying web framework for Adobe AEM. While the main concept of resource handling is well known, the project contains some hidden gems. Learn some fun facts about the open source project together with very valuable insight into important bits and pieces making the life of an application developer easier. This is a developer focused journey into the "secrets" of Apache Sling.
Apigility – Lightning Fast API Development - OSSCamp 2014 OSSCube
Apigility - The world's easiest way to create high-quality APIs.
Apigility is an API Builder, designed to simplify
creating and maintaining useful, easy to consume, and
well structured APIs. Regardless of your experience in
API building, with Apigility you can build APIs that
enable mobile apps, developer communities, and any
other consumer controlled access to your applications.
Maarten Balliauw "Indexing and searching NuGet.org with Azure Functions and S...Fwdays
Which NuGet package was that type in again? In this session, let's build a "reverse package search" that helps to find the correct NuGet package based on a public type name.
Together, we will create a highly-scalable serverless search engine using Azure Functions and Azure Search that performs 3 tasks: listening for new packages on NuGet.org (using a custom binding), indexing packages in a distributed way, and exposing an API that accepts queries and gives our clients the best result. Expect code, insights into the service design process, and more!
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...Maarten Balliauw
Which NuGet package was that type in again? In this session, let's build a "reverse package search" that helps finding the correct NuGet package based on a public type.
Together, we will create a highly-scalable serverless search engine using Azure Functions and Azure Search that performs 3 tasks: listening for new packages on NuGet.org (using a custom binding), indexing packages in a distributed way, and exposing an API that accepts queries and gives our clients the best result.
Building Beautiful REST APIs with ASP.NET CoreStormpath
Join Stormpath .NET Developer Evangelist, Nate Barbettini, to learn best practices for designing your REST API in ASP.NET Core. Nate will explain how to build HATEOS-compliant JSON APIs while supporting security best practices and even improving performance and scale.
Topics Covered:
What is REST and HATEOS?
How to think about RESTful APIs
How to model hypermedia in C#
Building JSON APIs in ASP.NET Core
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...Caktus Group
Originally presented by Charlotte Mays at DjangoCon 2017. Abstract: Since the combination of Django and DRF makes it so easy to get a simple API running, it becomes a very powerful, flexible, and expandable tool for a variety of uses. The only thing these applications may have in common is their need to share data across the web. Whether you have not yet tested the waters of Django Rest Framework or you are a DRF veteran, this talk will inspire you to think both big and small when considering its potential uses.
Apache Sling as an OSGi-powered REST middlewareRobert Munteanu
Apache Sling is an innovative web framework built on top of the Java Content Repository (JCR), that uses OSGi for its component model and fosters RESTful application design.
This presentation will showcase how the Apache Sling framework can be used to build a unified REST-based middleware for multiple data sources, such as MongoDB, Apache Cassandra, Apache Jackrabbit Oak or classical relational databases. In doing so it will present the benefits that come from a single Resource API over multiple data stores, both at the library level and at the HTTP boundary.
Effective Web Application Development with Apache SlingRobert Munteanu
Apache Sling is an innovative web framework built on top of the Java Content Repository (JCR), that uses OSGi for its component model and fosters RESTful application design.
This talk shows how Sling integrates various standard-based technologies, like OSGi and the Content Repository API for Java to create a coherent framework for web application development. We will walk through the development of a simple application with minimal effort and demonstrate how to productize the resulting application.
We will pay special attention to some approaches which are not yet part of mainstream development, such as using OSGi for dependecy injection and JCR for persistence.
With Grails 3, the plugin development experience changes a little bit compared to that of Grails 2. In this talk, Álvaro (member of the Grails team at OCI, Grails committer and author of several plugins) will cover several topics to understand how plugins work in Grails 3, focusing on best practices.
The session is structured as a set of tips and tricks with code samples in the following areas: modularisation, build system, testing and publishing.
Building domain-specific testing tools : lessons learned from the Apache Slin...Robert Munteanu
The Apache Sling project has built a number of testing tools which aid in testing applications that are built on top of this framework - REST-based, assembled using OSGi and backed by JCR.
We will review how those testing tools fit in with domain-agnostic testing tools such as JUnit and Mockito and what the benefits and pitfalls are when building your own domain-specific tools.
Similar techniques apply to projects not using the same technology stack, so the discussion will bring value to all projects which can benefit from domain-specific testing tools.
CIRCUIT 2015 - 10 Things Apache Sling Can DoICF CIRCUIT
Presented by Carsten Ziegeler & David Bosschaert from Adobe
Apache Sling is the underlying web framework for Adobe AEM. While the main concept of resource handling is well known, the project contains some hidden gems. Learn some fun facts about the open source project together with very valuable insight into important bits and pieces making the life of an application developer easier. This is a developer focused journey into the "secrets" of Apache Sling.
Apigility – Lightning Fast API Development - OSSCamp 2014 OSSCube
Apigility - The world's easiest way to create high-quality APIs.
Apigility is an API Builder, designed to simplify
creating and maintaining useful, easy to consume, and
well structured APIs. Regardless of your experience in
API building, with Apigility you can build APIs that
enable mobile apps, developer communities, and any
other consumer controlled access to your applications.
Maarten Balliauw "Indexing and searching NuGet.org with Azure Functions and S...Fwdays
Which NuGet package was that type in again? In this session, let's build a "reverse package search" that helps to find the correct NuGet package based on a public type name.
Together, we will create a highly-scalable serverless search engine using Azure Functions and Azure Search that performs 3 tasks: listening for new packages on NuGet.org (using a custom binding), indexing packages in a distributed way, and exposing an API that accepts queries and gives our clients the best result. Expect code, insights into the service design process, and more!
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...Maarten Balliauw
Which NuGet package was that type in again? In this session, let's build a "reverse package search" that helps finding the correct NuGet package based on a public type.
Together, we will create a highly-scalable serverless search engine using Azure Functions and Azure Search that performs 3 tasks: listening for new packages on NuGet.org (using a custom binding), indexing packages in a distributed way, and exposing an API that accepts queries and gives our clients the best result.
Building Beautiful REST APIs with ASP.NET CoreStormpath
Join Stormpath .NET Developer Evangelist, Nate Barbettini, to learn best practices for designing your REST API in ASP.NET Core. Nate will explain how to build HATEOS-compliant JSON APIs while supporting security best practices and even improving performance and scale.
Topics Covered:
What is REST and HATEOS?
How to think about RESTful APIs
How to model hypermedia in C#
Building JSON APIs in ASP.NET Core
Write an API for Almost Anything: The Amazing Power and Flexibility of Django...Caktus Group
Originally presented by Charlotte Mays at DjangoCon 2017. Abstract: Since the combination of Django and DRF makes it so easy to get a simple API running, it becomes a very powerful, flexible, and expandable tool for a variety of uses. The only thing these applications may have in common is their need to share data across the web. Whether you have not yet tested the waters of Django Rest Framework or you are a DRF veteran, this talk will inspire you to think both big and small when considering its potential uses.
APIdays Paris 2014 - Workshop - Craft and Deploy Your API in a Few Clicks Wit...Restlet
This workshop explained how to craft an API using the first multi-language dedicated Web IDE, host and scale the API with Platform as a Service for web APIs and manage access to this API; including: documentation, client SDKs, access management, firewall and analytics.
Apigility is a tool introduced in 2013 by Zend and the Zend Framework community, designed to handle in a simple graphical interface the configuration, management and creation of APIs, and provides classes to support API development.
This presentation is a quick but hopefully interesting introduction to this tool, aiming to demonstrate some of the most important features.
Apigility is a tool introduced in 2013 by Zend and the Zend Framework community, designed to handle in a simple graphical interface the configuration, management and creation of APIs, and provides classes to support API development.
This presentation is a quick but hopefully interesting introduction to this tool, aiming to demonstrate some of the most important features.
GraphQL, an open-source data query and manipulation language for APIs, is gaining popularity due to the flexibility associated with its usage. Organizations are adopting this new technology as a means of enabling rapid application development. However, the challenges and concerns associated with exposing GraphQL services for application developers are different from the traditional REST or SOAP based endpoints. This introduces a need to adopt an API management platform that specifically treats GraphQL characteristics as first-class citizens.
This slide deck will
• Give an introduction to GraphQL
• Compare GraphQL with REST
• Explore the considerations when adopting an API management platform for GraphQL
Meetup recording: https://youtu.be/wLTZhT6hc7s
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Fwdays
Are you ready for production? Are you sure? Is your application prefetchable? Is it readable for search engine robots? Will it fit into Content Delivery Network? Do you want to make it even faster? Meet the Server-Side Rendering concept. Learn how to implement it in your application and gain knowledge about best practices, such as transfer state and route resolving strategies.
Choreo Community Call 1: How to Create a Service in Choreo!
Agenda:
1. Introduction to Choreo
2. Introduction to Service Components
- What are Service components and its use cases
- Capabilities
3. Demo
- Deploy a Todo list web application
Watch the video at : https://youtube.com/live/FX06RgpNUB4
GraphQL is an emerging query manipulation language for APIs. It is an open source runtime for querying and retrieving existing data in an optimal manner making applications more efficient. With the flexibility it offers over REST APIs, many organizations are now interested in and are adopting GraphQL applications widely.
While GraphQL focuses on what it does best, backend developers still worry about ensuring their GraphQL services are exposed in a secure, controlled, monitored, and sometimes, even in a monetized environment. This is where an API gateway is useful as the middle layer to provide a significant value to GraphQL queries, mutations, and subscriptions.
This slide deck will discuss the following:
- An introduction to GraphQL
- Why and when to use GraphQL APIs
- Exposing GraphQL service as managed APIs: The necessity of an API Manager
- Deploying a GraphQL service via WSO2 API Manager : Security, authentication, authorization, and rate-limiting
- Invoking GraphQL APIs via the integrated GraphiQL UI in Developer Portal
- GraphQL Analytics
Watch the webinar on-demand here: https://wso2.com/library/webinars/deploying-graphql-services-as-managed-apis/
Similar to Write an API for Almost Anything: The Amazing Power and Flexibility of Django Rest Framework (20)
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Knowledge engineering: from people to machines and back
Write an API for Almost Anything: The Amazing Power and Flexibility of Django Rest Framework
1. Write an API for Almost Anything
DjangoCon 2017
The Amazing Power and Flexibility of
Django Rest Framework
2. Who Am I?
● Web Developer at Caktus Group
● Organizer of PyLadies RDU
● Builder and User of APIs
Note: Slides available at:
http://cakt.us/DjangoCon2017talk
3. What does “API” mean, anyway?
● “Application Programming Interface”
● Definition (techtarget.com): “An application program
interface (API) is
code that allows two software programs to
communicate with each other.”
4. Why Are APIs Useful?
● Flexibility
● Access (internally and externally)
● Future-proofing
5. Example: Customized Output
●Massage therapist needed schedule
information to be sharable without client
information
● Scheduling software did not do this
○ But did have an API!
6. Example: Customized Output
● Small script can pull schedule information
and post without client information to a
shareable calendar
● API made it possible to create an otherwise
nonexistent feature
7. APIs for Non-Web Applications
● Easy and practical enough to be useful for
other distributed applications
● Example: Game back-end
○ https://github.com/flowerncsu/ecgc-2017
8. Internal Separation
● Dynamic, highly interactive pages require
JavaScript
● Use API to separate Django code from
JavaScript code
11. Building an API
● Many ways, many packages
● Django Rest Framework
○ Sits nicely on top of existing Django code
○ Very thorough feature set
12. Anatomy of Django Rest Framework
API
Router
ViewSet
Serializer
Django Models/
Database
serializers.py
views.py
urls.py
13. Anatomy of Django Rest Framework
API
Serializer
Django Models/
Database
14. Building the Serializer
from rest_framework import serializers
from .models import MyModel
class MyModelSerializer(serializers.ModelSerializer):
class Meta:
model = MyModel
fields = (
'id',
'name',
'category',
)
15. Anatomy of Django Rest Framework
API
ViewSet
Serializer
Django Models/
Database
16. Building the ViewSet
from rest_framework import viewsets
from .models import MyModel
from .serializers import MyModelSerializer
class MyModelViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows MyModel instances
to be viewed or edited.
"""
queryset = MyModel.objects.all()
serializer_class = MyModelSerializer
17. Anatomy of Django Rest Framework
API
Router
ViewSet
Serializer
Django Models/
Database
18. Building URLs with the Router
from django.conf.urls import url, include
from rest_framework import routers
from myapp import views as myapp_api
router = routers.DefaultRouter()
router.register(r'mymodel', myapp_api.MyModelViewSet)
urlpatterns = [
url(r'^', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls',
namespace='rest_framework'))
]
22. Accessing the API
HTTP Methods
● POST
● GET
● PUT
● PATCH
Operations
● Create
● Read
● Update
● D
23. Accessing the API
HTTP Methods
● POST
● GET
● PUT
● PATCH
● DELETE
Operations
● Create
● Read
● Update
● Delete
24. Accessing the API
HTTP Methods
● POST
● GET
● PUT
● PATCH
● DELETE
Operations
● Create
● Read
● Update
● Delete
25. Accessing the API
router.register(r'mymodel', myapp_api.MyModelViewSet)
(GET) myapp.com/mymodel
-> List of instances, fields based on serializer
(POST) myapp.com/mymodel
-> Create a new instance
(GET) myapp.com/mymodel/instance_id
-> Get details for instance with instance_id
(DELETE) myapp.com/mymodel/instance_id
-> Delete instance with instance_id
More information:
http://www.django-rest-framework.org/api-guide/viewsets/
26. What If I Don’t Want Users Doing That?
Several options to protect data:
● Authentication
● Read-only Viewsets
● Restricting specific actions
27. Documentation
● Key to usability of the API
● Structure is predictable
○ URL and HTTP method
○ Operation performed at that URL/method
○ Parameters expected
○ Data format returned
More information:
http://www.django-rest-framework.org/topics/documenting-your-api/
28. Automatic Documentation
from rest_framework.documentation import include_docs_urls
...
urlpatterns = [
...
url(r'^docs/', include_docs_urls(title='My API'))
]
More information:
http://www.django-rest-framework.org/topics/documenting-your-api/
29. Tests
● API functionality can be tested simply
● Automated tests mean “set it and forget it”
● Test failures can highlight changes that
should be reflected in documentation
30. Sample Test
from rest_framework.test import APITestCase
class TestMyModelViewSet(APITestCase):
def setUp(self):
self.url = reverse('mymodel-list')
self.instances = [MyModel() for i in range(3)]
for item in self.instances:
item.save()
def test_list_view(self):
response = self.client.get(self.url, format='json')
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 3)
More information:
http://www.django-rest-framework.org/api-guide/testing/
32. Homework!
● What Django projects do you have live?
○ In development?
● Do they have public information?
● Collections of user data?
● Can’t think of a use? Users will!
33. Resources
Django Rest Framework Quickstart:
http://www.django-rest-framework.org/tutorial/quickstart/
Example Project:
https://github.com/flowerncsu/ecgc-2017
These Slides:
http://cakt.us/DjangoCon2017talk
Caktus Group:
@caktusgroup
https://www.caktusgroup.com/
My Twitter:
@charlottecodes